00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CONVERTSHAPE_H
00020 #define CONVERTSHAPE_H
00021
00022 class IDataSource;
00023 class ODataSource;
00024
00025
00026
00027
00028 struct ConvertShapeFormat
00029 {
00030 const char * name;
00031
00032 uint32 len_header;
00033 const char * ident;
00034 uint32 bytes_ident;
00035 uint32 bytes_special;
00036 uint32 bytes_header_unk;
00037 uint32 bytes_num_frames;
00038
00039 uint32 len_frameheader;
00040 uint32 bytes_frame_offset;
00041 uint32 bytes_frameheader_unk;
00042 uint32 bytes_frame_length;
00043 uint32 bytes_frame_length_kludge;
00044
00045 uint32 len_frameheader2;
00046 uint32 bytes_frame_unknown;
00047 uint32 bytes_frame_compression;
00048 uint32 bytes_frame_width;
00049 uint32 bytes_frame_height;
00050 uint32 bytes_frame_xoff;
00051 uint32 bytes_frame_yoff;
00052
00053 uint32 bytes_line_offset;
00054 uint32 line_offset_absolute;
00055 };
00056
00057
00058
00059 struct ConvertShapeFrame
00060 {
00061 uint8 header_unknown[2];
00062
00063 uint8 unknown[8];
00064 uint32 compression;
00065 sint32 width;
00066 sint32 height;
00067 sint32 xoff;
00068 sint32 yoff;
00069
00070 uint32 *line_offsets;
00071
00072 sint32 bytes_rle;
00073 uint8 *rle_data;
00074
00075 void Free()
00076 {
00077 delete [] line_offsets;
00078 line_offsets = 0;
00079
00080 delete [] rle_data;
00081 rle_data = 0;
00082 }
00083
00084 void Read(IDataSource *source, const ConvertShapeFormat *csf, uint32 frame_length);
00085
00086 void ReadCmpFrame(IDataSource *source, const ConvertShapeFormat *csf, const uint8 special[256], ConvertShapeFrame *prev);
00087
00088 void GetPixels(uint8 *buf, sint32 count, sint32 x, sint32 y);
00089 };
00090
00091
00092
00093
00094 class ConvertShape
00095 {
00096 uint8 header_unknown[4];
00097 uint32 num_frames;
00098 ConvertShapeFrame *frames;
00099
00100 public:
00101 ConvertShape() : num_frames(0), frames(0)
00102 {
00103 }
00104
00105 ~ConvertShape()
00106 {
00107 Free();
00108 }
00109
00110 void Free()
00111 {
00112 if (frames)
00113 for(uint32 i = 0; i < num_frames; ++i)
00114 frames[i].Free();
00115
00116 delete [] frames;
00117 frames = 0;
00118 num_frames = 0;
00119 }
00120
00121
00122 void Read(IDataSource *source, const ConvertShapeFormat *csf, uint32 real_len);
00123 void Write(ODataSource *source, const ConvertShapeFormat *csf, uint32 &write_len);
00124
00125
00126 static bool Check(IDataSource *source, const ConvertShapeFormat *csf, uint32 real_len);
00127
00128
00129
00130 static bool CheckUnsafe(IDataSource *source, const ConvertShapeFormat *csf, uint32 real_len);
00131
00132
00133 static int CalcNumFrames(IDataSource *source, const ConvertShapeFormat *csf, uint32 real_len, uint32 start_pos);
00134 };
00135
00136
00137 extern const ConvertShapeFormat PentagramShapeFormat;
00138
00139 #endif //CONVERTSHAPE_H