| 1 | // Aseprite Document IO Library |
| 2 | // Copyright (c) 2018-2020 Igara Studio S.A. |
| 3 | // Copyright (c) 2017 David Capello |
| 4 | // |
| 5 | // This file is released under the terms of the MIT license. |
| 6 | // Read LICENSE.txt for more information. |
| 7 | |
| 8 | #ifndef DIO_ASEPRITE_DECODER_H_INCLUDED |
| 9 | #define DIO_ASEPRITE_DECODER_H_INCLUDED |
| 10 | #pragma once |
| 11 | |
| 12 | #include "dio/decoder.h" |
| 13 | #include "doc/frame.h" |
| 14 | #include "doc/layer_list.h" |
| 15 | #include "doc/pixel_format.h" |
| 16 | #include "doc/slices.h" |
| 17 | #include "doc/tags.h" |
| 18 | |
| 19 | #include <string> |
| 20 | #include <vector> |
| 21 | |
| 22 | namespace doc { |
| 23 | class Cel; |
| 24 | class Layer; |
| 25 | class Layer; |
| 26 | class Mask; |
| 27 | class Palette; |
| 28 | class Sprite; |
| 29 | class UserData; |
| 30 | } |
| 31 | |
| 32 | namespace dio { |
| 33 | |
| 34 | struct ; |
| 35 | struct ; |
| 36 | struct AsepriteExternalFiles; |
| 37 | |
| 38 | class AsepriteDecoder : public Decoder { |
| 39 | public: |
| 40 | bool decode() override; |
| 41 | |
| 42 | private: |
| 43 | bool (AsepriteHeader* ); |
| 44 | void (AsepriteFrameHeader* ); |
| 45 | void readPadding(const int bytes); |
| 46 | std::string readString(); |
| 47 | doc::Palette* readColorChunk(doc::Palette* prevPal, doc::frame_t frame); |
| 48 | doc::Palette* readColor2Chunk(doc::Palette* prevPal, doc::frame_t frame); |
| 49 | doc::Palette* readPaletteChunk(doc::Palette* prevPal, doc::frame_t frame); |
| 50 | doc::Layer* (AsepriteHeader* , doc::Sprite* sprite, doc::Layer** previous_layer, int* current_level); |
| 51 | doc::Cel* (doc::Sprite* sprite, |
| 52 | doc::frame_t frame, |
| 53 | doc::PixelFormat pixelFormat, |
| 54 | const AsepriteHeader* , |
| 55 | const size_t chunk_end); |
| 56 | void (doc::Cel* cel); |
| 57 | void readColorProfile(doc::Sprite* sprite); |
| 58 | void readExternalFiles(AsepriteExternalFiles& extFiles); |
| 59 | doc::Mask* readMaskChunk(); |
| 60 | void readTagsChunk(doc::Tags* tags); |
| 61 | void readSlicesChunk(doc::Slices& slices); |
| 62 | doc::Slice* readSliceChunk(doc::Slices& slices); |
| 63 | void readUserDataChunk(doc::UserData* userData); |
| 64 | void (doc::Sprite* sprite, |
| 65 | const AsepriteHeader* , |
| 66 | const AsepriteExternalFiles& extFiles); |
| 67 | |
| 68 | doc::LayerList m_allLayers; |
| 69 | std::vector<uint32_t> m_tilesetFlags; |
| 70 | }; |
| 71 | |
| 72 | } // namespace dio |
| 73 | |
| 74 | #endif |
| 75 | |