1 // Aseprite Document Library
2 // Copyright (c) 2001-2016 David Capello
3 //
4 // This file is released under the terms of the MIT license.
5 // Read LICENSE.txt for more information.
6
7 #ifdef HAVE_CONFIG_H
8 #include "config.h"
9 #endif
10
11 #include "doc/cel_data.h"
12
13 #include "gfx/rect.h"
14 #include "doc/image.h"
15 #include "doc/layer.h"
16 #include "doc/sprite.h"
17
18 namespace doc {
19
CelData(const ImageRef & image)20 CelData::CelData(const ImageRef& image)
21 : WithUserData(ObjectType::CelData)
22 , m_image(image)
23 , m_opacity(255)
24 , m_bounds(0, 0,
25 image ? image->width(): 0,
26 image ? image->height(): 0)
27 , m_boundsF(nullptr)
28 {
29 }
30
CelData(const CelData & celData)31 CelData::CelData(const CelData& celData)
32 : WithUserData(ObjectType::CelData)
33 , m_image(celData.m_image)
34 , m_opacity(celData.m_opacity)
35 , m_bounds(celData.m_bounds)
36 , m_boundsF(celData.m_boundsF ? new gfx::RectF(*celData.m_boundsF):
37 nullptr)
38 {
39 }
40
~CelData()41 CelData::~CelData()
42 {
43 delete m_boundsF;
44 }
45
setImage(const ImageRef & image)46 void CelData::setImage(const ImageRef& image)
47 {
48 ASSERT(image.get());
49
50 m_image = image;
51 m_bounds.w = image->width();
52 m_bounds.h = image->height();
53 }
54
55 } // namespace doc
56