1 | // Aseprite Document IO Library |
2 | // Copyright (c) 2017 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 DIO_DECODE_DELEGATE_H_INCLUDED |
8 | #define DIO_DECODE_DELEGATE_H_INCLUDED |
9 | #pragma once |
10 | |
11 | #include "doc/color.h" |
12 | #include "doc/frame.h" |
13 | #include "doc/sprite.h" |
14 | |
15 | #include <string> |
16 | |
17 | namespace dio { |
18 | |
19 | class DecodeDelegate { |
20 | public: |
21 | virtual ~DecodeDelegate() { } |
22 | |
23 | // Used to log errors |
24 | virtual void error(const std::string& msg) { } |
25 | |
26 | // Used to report progress of the whole operation |
27 | virtual void progress(double fromZeroToOne) { } |
28 | |
29 | // Return true if the operation was cancelled by the user |
30 | virtual bool isCanceled() { return false; } |
31 | |
32 | // Return true if you want to read just the first frame (e.g. useful |
33 | // to generate a thumbnail) |
34 | virtual bool decodeOneFrame() { return false; } |
35 | |
36 | // Default color for slices without user data |
37 | virtual doc::color_t defaultSliceColor() { |
38 | return doc::rgba(0, 0, 255, 255); |
39 | } |
40 | |
41 | // Called when the sprite is decoded successfully |
42 | virtual void onSprite(doc::Sprite* sprite) { |
43 | // Discard the sprite, you should overwrite this behavior, use the |
44 | // sprite and then discard it when you don't need it anymore. |
45 | delete sprite; |
46 | } |
47 | }; |
48 | |
49 | } // namespace dio |
50 | |
51 | #endif |
52 | |