• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KImgIO

xcf.h

Go to the documentation of this file.
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 <qimage.h>
00025 #include <qiodevice.h>
00026 #include <qvaluestack.h>
00027 #include <qvaluevector.h>
00028 
00029 #include "gimp.h"
00030 
00031 
00032 extern "C" {
00033 void kimgio_xcf_read(QImageIO *);
00034 void kimgio_xcf_write(QImageIO *);
00035 }
00036 
00037 const float INCHESPERMETER = (100.0 / 2.54);
00038 
00046 typedef QValueVector<QValueVector<QImage> > Tiles;
00047 
00048 
00049 
00050 class XCFImageFormat {
00051 public:
00052     XCFImageFormat();
00053     void readXCF(QImageIO* image_io);
00054 
00055 
00056 private:
00065     class Layer {
00066     public:
00067         Q_UINT32 width;         
00068         Q_UINT32 height;        
00069         Q_INT32 type;           
00070         char* name;         
00071         Q_UINT32 hierarchy_offset;  
00072         Q_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             Q_UINT32 opacity;
00086             Q_UINT32 visible;
00087             Q_UINT32 show_masked;
00088             uchar red, green, blue;
00089             Q_UINT32 tattoo;
00090         } mask_channel;
00091 
00092         bool active;            
00093         Q_UINT32 opacity;       
00094         Q_UINT32 visible;       
00095         Q_UINT32 linked;        
00096         Q_UINT32 preserve_transparency; 
00097         Q_UINT32 apply_mask;        
00098         Q_UINT32 edit_mask;     
00099         Q_UINT32 show_mask;     
00100         Q_INT32 x_offset;       
00101         Q_INT32 y_offset;       
00102         Q_UINT32 mode;          
00103         Q_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         Q_UINT32 width;         
00126         Q_UINT32 height;        
00127         Q_INT32 type;           
00128 
00129         Q_UINT8 compression;        
00130         float x_resolution;     
00131         float y_resolution;     
00132         Q_INT32 tattoo;         
00133         Q_UINT32 unit;          
00134         Q_INT32 num_colors;     
00135         QValueVector<QRgb> palette; 
00136 
00137         int num_layers;         
00138         Layer layer;            
00139 
00140         bool initialized;       
00141         QImage 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             QImage& image, int m, int n);
00162 
00164     typedef void (*PixelMergeOperation)(Layer& layer, uint i, uint j, int k, int l,
00165             QImage& 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(QDataStream& xcf_io, XCFImage& image);
00177     bool loadProperty(QDataStream& xcf_io, PropType& type, QByteArray& bytes);
00178     bool loadLayer(QDataStream& xcf_io, XCFImage& xcf_image);
00179     bool loadLayerProperties(QDataStream& xcf_io, Layer& layer);
00180     bool composeTiles(XCFImage& xcf_image);
00181     void setGrayPalette(QImage& image);
00182     void setPalette(XCFImage& xcf_image, QImage& image);
00183     static void assignImageBytes(Layer& layer, uint i, uint j);
00184     bool loadHierarchy(QDataStream& xcf_io, Layer& layer);
00185     bool loadLevel(QDataStream& xcf_io, Layer& layer, Q_INT32 bpp);
00186     static void assignMaskBytes(Layer& layer, uint i, uint j);
00187     bool loadMask(QDataStream& xcf_io, Layer& layer);
00188     bool loadChannelProperties(QDataStream& xcf_io, Layer& layer);
00189     bool initializeImage(XCFImage& xcf_image);
00190     bool loadTileRLE(QDataStream& xcf_io, uchar* tile, int size,
00191             int data_length, Q_INT32 bpp);
00192     static void copyLayerToImage(XCFImage& xcf_image);
00193     static void copyRGBToRGB(Layer& layer, uint i, uint j, int k, int l,
00194             QImage& image, int m, int n);
00195 
00196     static void copyGrayToGray(Layer& layer, uint i, uint j, int k, int l,
00197             QImage& image, int m, int n);
00198     static void copyGrayToRGB(Layer& layer, uint i, uint j, int k, int l,
00199             QImage& image, int m, int n);
00200     static void copyGrayAToRGB(Layer& layer, uint i, uint j, int k, int l,
00201             QImage& image, int m, int n);
00202     static void copyIndexedToIndexed(Layer& layer, uint i, uint j, int k, int l,
00203             QImage& image, int m, int n);
00204     static void copyIndexedAToIndexed(Layer& layer, uint i, uint j, int k, int l,
00205             QImage& image, int m, int n);
00206     static void copyIndexedAToRGB(Layer& layer, uint i, uint j, int k, int l,
00207             QImage& 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             QImage& image, int m, int n);
00212     static void mergeGrayToGray(Layer& layer, uint i, uint j, int k, int l,
00213             QImage& image, int m, int n);
00214     static void mergeGrayAToGray(Layer& layer, uint i, uint j, int k, int l,
00215             QImage& image, int m, int n);
00216     static void mergeGrayToRGB(Layer& layer, uint i, uint j, int k, int l,
00217             QImage& image, int m, int n);
00218     static void mergeGrayAToRGB(Layer& layer, uint i, uint j, int k, int l,
00219             QImage& image, int m, int n);
00220     static void mergeIndexedToIndexed(Layer& layer, uint i, uint j, int k, int l,
00221             QImage& image, int m, int n);
00222     static void mergeIndexedAToIndexed(Layer& layer, uint i, uint j, int k, int l,
00223             QImage& image, int m, int n);
00224     static void mergeIndexedAToRGB(Layer& layer, uint i, uint j, int k, int l,
00225             QImage& image, int m, int n);
00226 
00227     static void dissolveRGBPixels(QImage& image, int x, int y);
00228     static void dissolveAlphaPixels(QImage& image, int x, int y);
00229 };
00230 
00231 #endif

KImgIO

Skip menu "KImgIO"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal