• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kimgio
 

kimgio

  • kimgio
xcf.h
1 #ifndef XCF_H
2 #define XCF_H
3 /*
4  * qxcfi.cpp: A Qt 3 plug-in for reading GIMP XCF image files
5  * Copyright (C) 2001 lignum Computing, Inc. <allen@lignumcomputing.com>
6  * Copyright (C) 2004 Melchior FRANZ <mfranz@kde.org>
7  *
8  * This plug-in is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 #include <tqimage.h>
25 #include <tqiodevice.h>
26 #include <tqvaluestack.h>
27 #include <tqvaluevector.h>
28 
29 #include "gimp.h"
30 
31 
32 extern "C" {
33 void kimgio_xcf_read(TQImageIO *);
34 void kimgio_xcf_write(TQImageIO *);
35 }
36 
37 const float INCHESPERMETER = (100.0 / 2.54);
38 
46 typedef TQValueVector<TQValueVector<TQImage> > Tiles;
47 
48 
49 
50 class XCFImageFormat {
51 public:
52  XCFImageFormat();
53  void readXCF(TQImageIO* image_io);
54 
55 
56 private:
65  class Layer {
66  public:
67  TQ_UINT32 width;
68  TQ_UINT32 height;
69  TQ_INT32 type;
70  char* name;
71  TQ_UINT32 hierarchy_offset;
72  TQ_UINT32 mask_offset;
73 
74  uint nrows;
75  uint ncols;
76 
77  Tiles image_tiles;
80  Tiles alpha_tiles;
81  Tiles mask_tiles;
82 
84  struct {
85  TQ_UINT32 opacity;
86  TQ_UINT32 visible;
87  TQ_UINT32 show_masked;
88  uchar red, green, blue;
89  TQ_UINT32 tattoo;
90  } mask_channel;
91 
92  bool active;
93  TQ_UINT32 opacity;
94  TQ_UINT32 visible;
95  TQ_UINT32 linked;
96  TQ_UINT32 preserve_transparency;
97  TQ_UINT32 apply_mask;
98  TQ_UINT32 edit_mask;
99  TQ_UINT32 show_mask;
100  TQ_INT32 x_offset;
101  TQ_INT32 y_offset;
102  TQ_UINT32 mode;
103  TQ_UINT32 tattoo;
104 
106  uchar tile[TILE_WIDTH * TILE_HEIGHT * sizeof(TQRgb)];
107 
112  void (*assignBytes)(Layer& layer, uint i, uint j);
113 
114  Layer(void) : name(0) {}
115  ~Layer(void) { delete[] name; }
116  };
117 
118 
123  class XCFImage {
124  public:
125  TQ_UINT32 width;
126  TQ_UINT32 height;
127  TQ_INT32 type;
128 
129  TQ_UINT8 compression;
130  float x_resolution;
131  float y_resolution;
132  TQ_INT32 tattoo;
133  TQ_UINT32 unit;
134  TQ_INT32 num_colors;
135  TQValueVector<TQRgb> palette;
136 
137  int num_layers;
138  Layer layer;
139 
140  bool initialized;
141  TQImage image;
142 
143  XCFImage(void) : initialized(false) {}
144  };
145 
146 
152  static int random_table[RANDOM_TABLE_SIZE];
153 
155  //static int add_lut[256][256]; - this is so lame waste of 256k of memory
156  static int add_lut( int, int );
157 
160  typedef void (*PixelCopyOperation)(Layer& layer, uint i, uint j, int k, int l,
161  TQImage& image, int m, int n);
162 
164  typedef void (*PixelMergeOperation)(Layer& layer, uint i, uint j, int k, int l,
165  TQImage& image, int m, int n);
166 
168  typedef struct {
169  bool affect_alpha;
170  } LayerModes;
171 
174  static const LayerModes layer_modes[];
175 
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);
195 
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);
208 
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);
226 
227  static void dissolveRGBPixels(TQImage& image, int x, int y);
228  static void dissolveAlphaPixels(TQImage& image, int x, int y);
229 };
230 
231 #endif

kimgio

Skip menu "kimgio"
  • Main Page
  • File List
  • Related Pages

kimgio

Skip menu "kimgio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kimgio by doxygen 1.9.1
This website is maintained by Timothy Pearson.