00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef EASYSOK_MNG_ANIMATION_STORER_INC_GUARD_H
00022 #define EASYSOK_MNG_ANIMATION_STORER_INC_GUARD_H
00023
00024
00025 #include "../config.h"
00026
00027
00028 #ifdef EASYSOK_HAVE_MNG
00029
00030
00031 #define MNG_BUILD_SO // Needed for writing capabilities
00032 #include <libmng.h>
00033
00034 #include <qpoint.h>
00035 #include <qrect.h>
00036
00037 #include <kurl.h>
00038
00039 #include "map.h"
00040 #include "movements.h"
00041 #include "pixmap_provider.h"
00042
00043
00044 class KTempFile;
00045 class QImage;
00046 class QPoint;
00047 class Theme;
00048
00049
00050
00051
00059 class MngAnimationStorer
00060 {
00061
00062 public:
00063
00068 virtual ~MngAnimationStorer();
00069
00070
00088 MngAnimationStorer(Map const & map, Movements const & moves, Theme const & theme, int piece_size,
00089 int use_background, int start_delay, int delay, bool cycle, int end_delay,
00090 bool low_quality, KURL const & url);
00091
00092
00093
00098 enum Result
00099 {
00104 OK,
00105
00106
00111 FINISHED,
00112
00113
00118 ERROR
00119 };
00120
00121
00126 virtual Result proccess();
00127
00128
00129 private:
00130
00137 QRect getBoundingRect(QPoint const & position) const;
00138
00139
00147 void createPngObject(int index, QImage const & image);
00148
00149
00157 void paintObject(int index, QPoint const & position);
00158
00159
00167 void paintPiece(QPoint const & position);
00168
00169
00177 static mng_ptr allocMNG(mng_size_t length);
00178
00179
00187 static void freeMNG(mng_ptr pointer, mng_size_t length);
00188
00189
00196 static mng_bool openMNG(mng_handle handle);
00197
00198
00205 static mng_bool closeMNG(mng_handle handle);
00206
00207
00217 static mng_bool writeMNG(mng_handle handle, mng_ptr buffer, mng_uint32 size, mng_uint32 * written);
00218
00219
00224 Map m_map;
00225
00226
00231 Movements m_moves;
00232
00233
00238 Theme const & m_theme;
00239
00240
00245 PixmapProvider m_pixmap_provider;
00246
00247
00252 int m_piece_size;
00253
00254
00259 QPoint m_offset;
00260
00261
00266 int m_keeper_direction;
00267
00268
00273 mng_handle m_handle;
00274
00275
00280 int m_background_width;
00281
00282
00287 int m_background_height;
00288
00289
00294 bool m_use_background;
00295
00296
00301 bool m_use_background_image;
00302
00303
00308 bool m_low_quality;
00309
00310
00315 int m_delay;
00316
00317
00322 KURL m_url;
00323
00324
00329 KTempFile * m_temp_file;
00330 };
00331
00332
00333 #endif
00334
00335
00336 #endif