forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextra_cel.cpp
52 lines (42 loc) · 1.25 KB
/
extra_cel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Aseprite
// Copyright (C) 2001-2016 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/extra_cel.h"
#include "doc/sprite.h"
namespace app {
ExtraCel::ExtraCel()
: m_type(render::ExtraType::NONE)
, m_blendMode(doc::BlendMode::NORMAL)
{
}
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->setBounds(bounds);
m_cel->setOpacity(opacity);
m_cel->setFrame(frame);
}
} // namespace app