forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecode_delegate.h
63 lines (48 loc) · 1.67 KB
/
decode_delegate.h
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
53
54
55
56
57
58
59
60
61
62
63
// Aseprite Document IO Library
// Copyright (c) 2023 Igara Studio S.A.
// Copyright (c) 2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef DIO_DECODE_DELEGATE_H_INCLUDED
#define DIO_DECODE_DELEGATE_H_INCLUDED
#pragma once
#include "doc/color.h"
#include "doc/frame.h"
#include "doc/sprite.h"
#include <string>
namespace dio {
class DecodeDelegate {
public:
virtual ~DecodeDelegate() { }
// Used to log errors
virtual void error(const std::string& msg) { }
// Sets an error when an incompatibility issue is
// detected.
virtual void incompatibilityError(const std::string &msg) { }
// Used to report progress of the whole operation
virtual void progress(double fromZeroToOne) { }
// Return true if the operation was cancelled by the user
virtual bool isCanceled() { return false; }
// Return true if you want to read just the first frame (e.g. useful
// to generate a thumbnail)
virtual bool decodeOneFrame() { return false; }
// Default color for slices without user data
virtual doc::color_t defaultSliceColor() {
return doc::rgba(0, 0, 255, 255);
}
// Called when the sprite is decoded successfully
virtual void onSprite(doc::Sprite* sprite) {
// Discard the sprite, you should overwrite this behavior, use the
// sprite and then discard it when you don't need it anymore.
delete sprite;
}
// Returns true if we want to cache the read compressed data of
// tilesets exactly as they are in the disk (so we can save it
// without re-compressing).
virtual bool cacheCompressedTilesets() const {
return false;
}
};
} // namespace dio
#endif