コード例 #1
0
ファイル: add_image.cpp プロジェクト: Skiles/aseprite
void AddImage::revert(ObjectsContainer* objects, UndoersCollector* redoers)
{
  Stock* stock = objects->getObjectT<Stock>(m_stockId);
  Image* image = stock->getImage(m_imageIndex);

  if (image == NULL)
    throw UndoException("One image was not found in the stock");

  redoers->pushUndoer(new RemoveImage(objects, stock, m_imageIndex));

  stock->removeImage(image);
  delete image;
}
コード例 #2
0
void ReplaceImage::revert(ObjectsContainer* objects, UndoersCollector* redoers)
{
  Stock* stock = objects->getObjectT<Stock>(m_stockId);

  // Read the image to be restored from the stream
  Image* image = read_object<Image>(objects, m_stream, raster::read_image);

  // Save the current image in the redoers
  redoers->pushUndoer(new ReplaceImage(objects, stock, m_imageIndex));
  Image* oldImage = stock->getImage(m_imageIndex);

  // Replace the image in the stock
  stock->replaceImage(m_imageIndex, image);

  // Destroy the old image
  delete oldImage;
}
コード例 #3
0
ファイル: cel.cpp プロジェクト: ololo1982/aseprite
Image* Cel::image() const
{
  ASSERT(m_layer != NULL);
  ASSERT(m_image >= 0);
  ASSERT(m_image < m_layer->sprite()->stock()->size());

  if (m_layer) {
    Stock* stock = m_layer->sprite()->stock();

    ASSERT(stock);
    ASSERT(m_image >= 0 && m_image < stock->size());

    if (m_image >= 0 && m_image < stock->size()) {
      Image* image = stock->getImage(m_image);
      ASSERT((m_image == 0 && !image) || (m_image != 0 && image));
      return image;
    }
  }

  return NULL;
}