Esempio n. 1
0
void ExtraCel::create(doc::Sprite* sprite,
                      const gfx::Rect& bounds,
                      doc::frame_t frame,
                      int opacity)
{
  ASSERT(sprite);

  if (!m_image ||
      m_image->pixelFormat() != sprite->pixelFormat() ||
      m_image->width() != bounds.w ||
      m_image->height() != bounds.h) {
    if (!m_imageBuffer)
      m_imageBuffer.reset(new doc::ImageBuffer(1));
    doc::Image* newImage = doc::Image::create(sprite->pixelFormat(),
                                              bounds.w, bounds.h,
                                              m_imageBuffer);
    m_image.reset(newImage);
  }

  if (!m_cel) {
    // Ignored fields for this cel (frame, and image index)
    m_cel.reset(new doc::Cel(doc::frame_t(0), doc::ImageRef(nullptr)));
  }

  m_cel->setPosition(bounds.getOrigin());
  m_cel->setOpacity(opacity);
  m_cel->setFrame(frame);
}
Esempio n. 2
0
void Document::prepareExtraCel(const gfx::Rect& bounds, int opacity)
{
  ASSERT(sprite() != NULL);

  if (!m_extraImage ||
      m_extraImage->pixelFormat() != sprite()->pixelFormat() ||
      m_extraImage->width() != bounds.w ||
      m_extraImage->height() != bounds.h) {
    Image* newImage = Image::create(sprite()->pixelFormat(), bounds.w, bounds.h);
    m_extraImage.reset(newImage);
  }

  if (!m_extraCel)
    m_extraCel = new Cel(frame_t(0), ImageRef(NULL)); // Ignored fields for this cel (frame, and image index)

  m_extraCel->setPosition(bounds.getOrigin());
  m_extraCel->setOpacity(opacity);
}