1 #pragma once
2 
3 #ifndef TTIO_SPRITE_INCLUDED
4 #define TTIO_SPRITE_INCLUDED
5 
6 #include "tproperty.h"
7 #include "tlevel_io.h"
8 #include "trasterimage.h"
9 #include <QVector>
10 #include <QStringList>
11 #include <QtGui/QImage>
12 #include <QCoreApplication>
13 
14 //===========================================================
15 //
16 //  TLevelWriterSprite
17 //
18 //===========================================================
19 
20 class TLevelWriterSprite : public TLevelWriter {
21 public:
22   TLevelWriterSprite(const TFilePath &path, TPropertyGroup *winfo);
23   ~TLevelWriterSprite();
24   void setFrameRate(double fps) override;
25 
26   TImageWriterP getFrameWriter(TFrameId fid) override;
27   void save(const TImageP &image, int frameIndex);
28 
29   void saveSoundTrack(TSoundTrack *st) override;
30 
create(const TFilePath & path,TPropertyGroup * winfo)31   static TLevelWriter *create(const TFilePath &path, TPropertyGroup *winfo) {
32     return new TLevelWriterSprite(path, winfo);
33   }
34 
35 private:
36   int m_lx, m_ly;
37   int m_scale;
38   int m_topPadding, m_bottomPadding, m_leftPadding, m_rightPadding;
39   int m_left = 0, m_right = 0, m_top = 0, m_bottom = 0;
40   std::vector<QImage *> m_images;
41   std::vector<QImage> m_imagesResized;
42   std::vector<int> m_frameIndexOrder;
43   bool m_firstPass = true;
44   bool m_trim      = true;
45   QString m_format;
46   // void *m_buffer;
47 };
48 
49 //===========================================================================
50 
51 namespace Tiio {
52 
53 //===========================================================================
54 
55 class SpriteWriterProperties : public TPropertyGroup {
56   Q_DECLARE_TR_FUNCTIONS(SpriteWriterProperties)
57 public:
58   TEnumProperty m_format;
59   TIntProperty m_topPadding, m_bottomPadding, m_leftPadding, m_rightPadding;
60   TIntProperty m_scale;
61   TBoolProperty m_trim;
62   SpriteWriterProperties();
63   void updateTranslation() override;
64 };
65 
66 //===========================================================================
67 
68 }  // namespace Tiio
69 
70 #endif
71