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

kimgio

xcf.h
00001 #ifndef XCF_H
00002 #define XCF_H
00003 /*
00004  * qxcfi.cpp: A Qt 3 plug-in for reading GIMP XCF image files
00005  * Copyright (C) 2001 lignum Computing, Inc. <allen@lignumcomputing.com>
00006  * Copyright (C) 2004 Melchior FRANZ <mfranz@kde.org>
00007  *
00008  * This plug-in is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00021  *
00022  */
00023 
00024 #include <tqimage.h>
00025 #include <tqiodevice.h>
00026 #include <tqvaluestack.h>
00027 #include <tqvaluevector.h>
00028 
00029 #include "gimp.h"
00030 
00031 
00032 extern "C" {
00033 void kimgio_xcf_read(TQImageIO *);
00034 void kimgio_xcf_write(TQImageIO *);
00035 }
00036 
00037 const float INCHESPERMETER = (100.0 / 2.54);
00038 
00046 typedef TQValueVector<TQValueVector<TQImage> > Tiles;
00047 
00048 
00049 
00050 class XCFImageFormat {
00051 public:
00052     XCFImageFormat();
00053     void readXCF(TQImageIO* image_io);
00054 
00055 
00056 private:
00065     class Layer {
00066     public:
00067         TQ_UINT32 width;            
00068         TQ_UINT32 height;       
00069         TQ_INT32 type;          
00070         char* name;         
00071         TQ_UINT32 hierarchy_offset; 
00072         TQ_UINT32 mask_offset;      
00073 
00074         uint nrows;         
00075         uint ncols;         
00076 
00077         Tiles image_tiles;      
00078 
00079 
00080         Tiles alpha_tiles;
00081         Tiles mask_tiles;       
00082 
00084         struct {
00085             TQ_UINT32 opacity;
00086             TQ_UINT32 visible;
00087             TQ_UINT32 show_masked;
00088             uchar red, green, blue;
00089             TQ_UINT32 tattoo;
00090         } mask_channel;
00091 
00092         bool active;            
00093         TQ_UINT32 opacity;      
00094         TQ_UINT32 visible;      
00095         TQ_UINT32 linked;       
00096         TQ_UINT32 preserve_transparency; 
00097         TQ_UINT32 apply_mask;       
00098         TQ_UINT32 edit_mask;        
00099         TQ_UINT32 show_mask;        
00100         TQ_INT32 x_offset;      
00101         TQ_INT32 y_offset;      
00102         TQ_UINT32 mode;         
00103         TQ_UINT32 tattoo;       
00104 
00106         uchar tile[TILE_WIDTH * TILE_HEIGHT * sizeof(QRgb)];
00107 
00112         void (*assignBytes)(Layer& layer, uint i, uint j);
00113 
00114         Layer(void) : name(0) {}
00115         ~Layer(void) { delete[] name; }
00116     };
00117 
00118 
00123     class XCFImage {
00124     public:
00125         TQ_UINT32 width;            
00126         TQ_UINT32 height;       
00127         TQ_INT32 type;          
00128 
00129         TQ_UINT8 compression;       
00130         float x_resolution;     
00131         float y_resolution;     
00132         TQ_INT32 tattoo;            
00133         TQ_UINT32 unit;         
00134         TQ_INT32 num_colors;        
00135         TQValueVector<QRgb> palette;    
00136 
00137         int num_layers;         
00138         Layer layer;            
00139 
00140         bool initialized;       
00141         TQImage image;          
00142 
00143         XCFImage(void) : initialized(false) {}
00144     };
00145 
00146 
00152     static int random_table[RANDOM_TABLE_SIZE];
00153 
00155     //static int add_lut[256][256]; - this is so lame waste of 256k of memory
00156     static int add_lut( int, int );
00157 
00160     typedef void (*PixelCopyOperation)(Layer& layer, uint i, uint j, int k, int l,
00161             TQImage& image, int m, int n);
00162 
00164     typedef void (*PixelMergeOperation)(Layer& layer, uint i, uint j, int k, int l,
00165             TQImage& image, int m, int n);
00166 
00168     typedef struct {
00169         bool affect_alpha;      
00170     } LayerModes;
00171 
00174     static const LayerModes layer_modes[];
00175 
00176     bool loadImageProperties(TQDataStream& xcf_io, XCFImage& image);
00177     bool loadProperty(TQDataStream& xcf_io, PropType& type, TQByteArray& bytes);
00178     bool loadLayer(TQDataStream& xcf_io, XCFImage& xcf_image);
00179     bool loadLayerProperties(TQDataStream& xcf_io, Layer& layer);
00180     bool composeTiles(XCFImage& xcf_image);
00181     void setGrayPalette(TQImage& image);
00182     void setPalette(XCFImage& xcf_image, TQImage& image);
00183     static void assignImageBytes(Layer& layer, uint i, uint j);
00184     bool loadHierarchy(TQDataStream& xcf_io, Layer& layer);
00185     bool loadLevel(TQDataStream& xcf_io, Layer& layer, TQ_INT32 bpp);
00186     static void assignMaskBytes(Layer& layer, uint i, uint j);
00187     bool loadMask(TQDataStream& xcf_io, Layer& layer);
00188     bool loadChannelProperties(TQDataStream& xcf_io, Layer& layer);
00189     bool initializeImage(XCFImage& xcf_image);
00190     bool loadTileRLE(TQDataStream& xcf_io, uchar* tile, int size,
00191             int data_length, TQ_INT32 bpp);
00192     static void copyLayerToImage(XCFImage& xcf_image);
00193     static void copyRGBToRGB(Layer& layer, uint i, uint j, int k, int l,
00194             TQImage& image, int m, int n);
00195 
00196     static void copyGrayToGray(Layer& layer, uint i, uint j, int k, int l,
00197             TQImage& image, int m, int n);
00198     static void copyGrayToRGB(Layer& layer, uint i, uint j, int k, int l,
00199             TQImage& image, int m, int n);
00200     static void copyGrayAToRGB(Layer& layer, uint i, uint j, int k, int l,
00201             TQImage& image, int m, int n);
00202     static void copyIndexedToIndexed(Layer& layer, uint i, uint j, int k, int l,
00203             TQImage& image, int m, int n);
00204     static void copyIndexedAToIndexed(Layer& layer, uint i, uint j, int k, int l,
00205             TQImage& image, int m, int n);
00206     static void copyIndexedAToRGB(Layer& layer, uint i, uint j, int k, int l,
00207             TQImage& image, int m, int n);
00208 
00209     static void mergeLayerIntoImage(XCFImage& xcf_image);
00210     static void mergeRGBToRGB(Layer& layer, uint i, uint j, int k, int l,
00211             TQImage& image, int m, int n);
00212     static void mergeGrayToGray(Layer& layer, uint i, uint j, int k, int l,
00213             TQImage& image, int m, int n);
00214     static void mergeGrayAToGray(Layer& layer, uint i, uint j, int k, int l,
00215             TQImage& image, int m, int n);
00216     static void mergeGrayToRGB(Layer& layer, uint i, uint j, int k, int l,
00217             TQImage& image, int m, int n);
00218     static void mergeGrayAToRGB(Layer& layer, uint i, uint j, int k, int l,
00219             TQImage& image, int m, int n);
00220     static void mergeIndexedToIndexed(Layer& layer, uint i, uint j, int k, int l,
00221             TQImage& image, int m, int n);
00222     static void mergeIndexedAToIndexed(Layer& layer, uint i, uint j, int k, int l,
00223             TQImage& image, int m, int n);
00224     static void mergeIndexedAToRGB(Layer& layer, uint i, uint j, int k, int l,
00225             TQImage& image, int m, int n);
00226 
00227     static void dissolveRGBPixels(TQImage& image, int x, int y);
00228     static void dissolveAlphaPixels(TQImage& image, int x, int y);
00229 };
00230 
00231 #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.7.6.1
This website is maintained by Timothy Pearson.