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 | #ifndef DOC_COMPRESSED_IMAGE_H_INCLUDED |
8 | #define DOC_COMPRESSED_IMAGE_H_INCLUDED |
9 | #pragma once |
10 | |
11 | #include "doc/color.h" |
12 | #include "doc/image.h" |
13 | |
14 | #include <vector> |
15 | |
16 | namespace doc { |
17 | |
18 | class CompressedImage { |
19 | public: |
20 | struct Scanline { |
21 | int x, y, w; |
22 | color_t color; |
23 | Scanline(int y) : x(0), y(y), w(0), color(0) { } |
24 | }; |
25 | |
26 | typedef std::vector<Scanline> Scanlines; |
27 | typedef Scanlines::const_iterator const_iterator; |
28 | |
29 | // If diffColors is true, it generates one Scanline instance for |
30 | // each different color. If it's false, it generates a scanline |
31 | // for each row of consecutive pixels different than the mask |
32 | // color. |
33 | CompressedImage(const Image* image, |
34 | const Image* maskBitmap, bool diffColors); |
35 | |
36 | const_iterator begin() const { return m_scanlines.begin(); } |
37 | const_iterator end() const { return m_scanlines.end(); } |
38 | |
39 | PixelFormat pixelFormat() const { return m_image->pixelFormat(); } |
40 | int width() const { return m_image->width(); } |
41 | int height() const { return m_image->height(); } |
42 | |
43 | private: |
44 | const Image* m_image; |
45 | Scanlines m_scanlines; |
46 | }; |
47 | |
48 | } // namespace doc |
49 | |
50 | #endif |
51 | |