25 #include <tqiodevice.h>
26 #include <tqvaluestack.h>
27 #include <tqvaluevector.h>
33 void kimgio_xcf_read(TQImageIO *);
34 void kimgio_xcf_write(TQImageIO *);
37 const float INCHESPERMETER = (100.0 / 2.54);
46 typedef TQValueVector<TQValueVector<TQImage> > Tiles;
50 class XCFImageFormat {
53 void readXCF(TQImageIO* image_io);
71 TQ_UINT32 hierarchy_offset;
72 TQ_UINT32 mask_offset;
87 TQ_UINT32 show_masked;
88 uchar red, green, blue;
96 TQ_UINT32 preserve_transparency;
106 uchar tile[TILE_WIDTH * TILE_HEIGHT *
sizeof(TQRgb)];
112 void (*assignBytes)(Layer& layer, uint i, uint j);
114 Layer(
void) : name(0) {}
115 ~Layer(
void) {
delete[] name; }
129 TQ_UINT8 compression;
135 TQValueVector<TQRgb> palette;
143 XCFImage(
void) : initialized(false) {}
152 static int random_table[RANDOM_TABLE_SIZE];
156 static int add_lut(
int,
int );
160 typedef void (*PixelCopyOperation)(Layer& layer, uint i, uint j,
int k,
int l,
161 TQImage& image,
int m,
int n);
164 typedef void (*PixelMergeOperation)(Layer& layer, uint i, uint j,
int k,
int l,
165 TQImage& image,
int m,
int n);
174 static const LayerModes layer_modes[];
176 bool loadImageProperties(TQDataStream& xcf_io, XCFImage& image);
177 bool loadProperty(TQDataStream& xcf_io, PropType& type, TQByteArray& bytes);
178 bool loadLayer(TQDataStream& xcf_io, XCFImage& xcf_image);
179 bool loadLayerProperties(TQDataStream& xcf_io, Layer& layer);
180 bool composeTiles(XCFImage& xcf_image);
181 void setGrayPalette(TQImage& image);
182 void setPalette(XCFImage& xcf_image, TQImage& image);
183 static void assignImageBytes(Layer& layer, uint i, uint j);
184 bool loadHierarchy(TQDataStream& xcf_io, Layer& layer);
185 bool loadLevel(TQDataStream& xcf_io, Layer& layer, TQ_INT32 bpp);
186 static void assignMaskBytes(Layer& layer, uint i, uint j);
187 bool loadMask(TQDataStream& xcf_io, Layer& layer);
188 bool loadChannelProperties(TQDataStream& xcf_io, Layer& layer);
189 bool initializeImage(XCFImage& xcf_image);
190 bool loadTileRLE(TQDataStream& xcf_io, uchar* tile,
int size,
191 int data_length, TQ_INT32 bpp);
192 static void copyLayerToImage(XCFImage& xcf_image);
193 static void copyRGBToRGB(Layer& layer, uint i, uint j,
int k,
int l,
194 TQImage& image,
int m,
int n);
196 static void copyGrayToGray(Layer& layer, uint i, uint j,
int k,
int l,
197 TQImage& image,
int m,
int n);
198 static void copyGrayToRGB(Layer& layer, uint i, uint j,
int k,
int l,
199 TQImage& image,
int m,
int n);
200 static void copyGrayAToRGB(Layer& layer, uint i, uint j,
int k,
int l,
201 TQImage& image,
int m,
int n);
202 static void copyIndexedToIndexed(Layer& layer, uint i, uint j,
int k,
int l,
203 TQImage& image,
int m,
int n);
204 static void copyIndexedAToIndexed(Layer& layer, uint i, uint j,
int k,
int l,
205 TQImage& image,
int m,
int n);
206 static void copyIndexedAToRGB(Layer& layer, uint i, uint j,
int k,
int l,
207 TQImage& image,
int m,
int n);
209 static void mergeLayerIntoImage(XCFImage& xcf_image);
210 static void mergeRGBToRGB(Layer& layer, uint i, uint j,
int k,
int l,
211 TQImage& image,
int m,
int n);
212 static void mergeGrayToGray(Layer& layer, uint i, uint j,
int k,
int l,
213 TQImage& image,
int m,
int n);
214 static void mergeGrayAToGray(Layer& layer, uint i, uint j,
int k,
int l,
215 TQImage& image,
int m,
int n);
216 static void mergeGrayToRGB(Layer& layer, uint i, uint j,
int k,
int l,
217 TQImage& image,
int m,
int n);
218 static void mergeGrayAToRGB(Layer& layer, uint i, uint j,
int k,
int l,
219 TQImage& image,
int m,
int n);
220 static void mergeIndexedToIndexed(Layer& layer, uint i, uint j,
int k,
int l,
221 TQImage& image,
int m,
int n);
222 static void mergeIndexedAToIndexed(Layer& layer, uint i, uint j,
int k,
int l,
223 TQImage& image,
int m,
int n);
224 static void mergeIndexedAToRGB(Layer& layer, uint i, uint j,
int k,
int l,
225 TQImage& image,
int m,
int n);
227 static void dissolveRGBPixels(TQImage& image,
int x,
int y);
228 static void dissolveAlphaPixels(TQImage& image,
int x,
int y);