• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KImgIO

  • sources
  • kde-4.14
  • kdelibs
  • kimgio
xcf.h
Go to the documentation of this file.
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 
25 #include <QtGui/QImageIOPlugin>
26 #include <QtGui/QImage>
27 #include <QtCore/QIODevice>
28 #include <QtCore/QVector>
29 
30 #include "gimp.h"
31 
32 class XCFHandler : public QImageIOHandler
33 {
34 public:
35  XCFHandler();
36 
37  bool canRead() const;
38  bool read(QImage *image);
39  bool write(const QImage &image);
40 
41  QByteArray name() const;
42 
43  static bool canRead(QIODevice *device);
44 };
45 
46 const float INCHESPERMETER = (100.0f / 2.54f);
47 
55 typedef QVector<QVector<QImage> > Tiles;
56 
57 
58 
59 class XCFImageFormat {
60 public:
61  XCFImageFormat();
62  bool readXCF(QIODevice *device, QImage *image);
63 
64 
65 private:
74  class Layer {
75  public:
76  quint32 width;
77  quint32 height;
78  qint32 type;
79  char* name;
80  quint32 hierarchy_offset;
81  quint32 mask_offset;
82 
83  uint nrows;
84  uint ncols;
85 
86  Tiles image_tiles;
87  Tiles alpha_tiles;
90  Tiles mask_tiles;
91 
93  struct {
94  quint32 opacity;
95  quint32 visible;
96  quint32 show_masked;
97  uchar red, green, blue;
98  quint32 tattoo;
99  } mask_channel;
100 
101  bool active;
102  quint32 opacity;
103  quint32 visible;
104  quint32 linked;
105  quint32 preserve_transparency;
106  quint32 apply_mask;
107  quint32 edit_mask;
108  quint32 show_mask;
109  qint32 x_offset;
110  qint32 y_offset;
111  quint32 mode;
112  quint32 tattoo;
113 
115  uchar tile[TILE_WIDTH * TILE_HEIGHT * sizeof(QRgb)];
116 
121  void (*assignBytes)(Layer& layer, uint i, uint j);
122 
123  Layer(void) : name(0) {}
124  ~Layer(void) { delete[] name; }
125  };
126 
127 
132  class XCFImage {
133  public:
134  quint32 width;
135  quint32 height;
136  qint32 type;
137 
138  quint8 compression;
139  float x_resolution;
140  float y_resolution;
141  qint32 tattoo;
142  quint32 unit;
143  qint32 num_colors;
144  QVector<QRgb> palette;
145 
146  int num_layers;
147  Layer layer;
148 
149  bool initialized;
150  QImage image;
151 
152  XCFImage(void) : initialized(false) {}
153  };
154 
155 
161  static int random_table[RANDOM_TABLE_SIZE];
162  static bool random_table_initialized;
163 
167  static QVector<QRgb> grayTable;
168 
170  //static int add_lut[256][256]; - this is so lame waste of 256k of memory
171  static int add_lut( int, int );
172 
175  typedef void (*PixelCopyOperation)(Layer& layer, uint i, uint j, int k, int l,
176  QImage& image, int m, int n);
177 
179  typedef void (*PixelMergeOperation)(Layer& layer, uint i, uint j, int k, int l,
180  QImage& image, int m, int n);
181 
183  typedef struct {
184  bool affect_alpha;
185  } LayerModes;
186 
189  static const LayerModes layer_modes[];
190 
191  bool loadImageProperties(QDataStream& xcf_io, XCFImage& image);
192  bool loadProperty(QDataStream& xcf_io, PropType& type, QByteArray& bytes);
193  bool loadLayer(QDataStream& xcf_io, XCFImage& xcf_image);
194  bool loadLayerProperties(QDataStream& xcf_io, Layer& layer);
195  bool composeTiles(XCFImage& xcf_image);
196  void setGrayPalette(QImage& image);
197  void setPalette(XCFImage& xcf_image, QImage& image);
198  static void assignImageBytes(Layer& layer, uint i, uint j);
199  bool loadHierarchy(QDataStream& xcf_io, Layer& layer);
200  bool loadLevel(QDataStream& xcf_io, Layer& layer, qint32 bpp);
201  static void assignMaskBytes(Layer& layer, uint i, uint j);
202  bool loadMask(QDataStream& xcf_io, Layer& layer);
203  bool loadChannelProperties(QDataStream& xcf_io, Layer& layer);
204  bool initializeImage(XCFImage& xcf_image);
205  bool loadTileRLE(QDataStream& xcf_io, uchar* tile, int size,
206  int data_length, qint32 bpp);
207 
208  static void copyLayerToImage(XCFImage& xcf_image);
209  static void copyRGBToRGB(Layer& layer, uint i, uint j, int k, int l,
210  QImage& image, int m, int n);
211  static void copyGrayToGray(Layer& layer, uint i, uint j, int k, int l,
212  QImage& image, int m, int n);
213  static void copyGrayToRGB(Layer& layer, uint i, uint j, int k, int l,
214  QImage& image, int m, int n);
215  static void copyGrayAToRGB(Layer& layer, uint i, uint j, int k, int l,
216  QImage& image, int m, int n);
217  static void copyIndexedToIndexed(Layer& layer, uint i, uint j, int k, int l,
218  QImage& image, int m, int n);
219  static void copyIndexedAToIndexed(Layer& layer, uint i, uint j, int k, int l,
220  QImage& image, int m, int n);
221  static void copyIndexedAToRGB(Layer& layer, uint i, uint j, int k, int l,
222  QImage& image, int m, int n);
223 
224  static void mergeLayerIntoImage(XCFImage& xcf_image);
225  static void mergeRGBToRGB(Layer& layer, uint i, uint j, int k, int l,
226  QImage& image, int m, int n);
227  static void mergeGrayToGray(Layer& layer, uint i, uint j, int k, int l,
228  QImage& image, int m, int n);
229  static void mergeGrayAToGray(Layer& layer, uint i, uint j, int k, int l,
230  QImage& image, int m, int n);
231  static void mergeGrayToRGB(Layer& layer, uint i, uint j, int k, int l,
232  QImage& image, int m, int n);
233  static void mergeGrayAToRGB(Layer& layer, uint i, uint j, int k, int l,
234  QImage& image, int m, int n);
235  static void mergeIndexedToIndexed(Layer& layer, uint i, uint j, int k, int l,
236  QImage& image, int m, int n);
237  static void mergeIndexedAToIndexed(Layer& layer, uint i, uint j, int k, int l,
238  QImage& image, int m, int n);
239  static void mergeIndexedAToRGB(Layer& layer, uint i, uint j, int k, int l,
240  QImage& image, int m, int n);
241 
242  static void initializeRandomTable();
243  static void dissolveRGBPixels(QImage& image, int x, int y);
244  static void dissolveAlphaPixels(QImage& image, int x, int y);
245 };
246 
247 #endif
QIODevice
INCHESPERMETER
const float INCHESPERMETER
Definition: xcf.h:46
RANDOM_TABLE_SIZE
const int RANDOM_TABLE_SIZE
Size of dissolve random number table.
Definition: gimp.h:39
QImageIOHandler::device
QIODevice * device() const
gimp.h
QByteArray
XCFHandler::canRead
bool canRead() const
Definition: xcf.cpp:2372
QDataStream
PropType
PropType
Properties which can be stored in an XCF file.
Definition: gimp.h:106
XCFImageFormat::XCFImageFormat
XCFImageFormat()
Definition: xcf.cpp:76
XCFHandler::read
bool read(QImage *image)
Definition: xcf.cpp:2381
XCFHandler
Definition: xcf.h:32
XCFHandler::name
QByteArray name() const
Definition: xcf.cpp:2392
XCFHandler::XCFHandler
XCFHandler()
Definition: xcf.cpp:2368
TILE_HEIGHT
const uint TILE_HEIGHT
Height of a tile in the XCF file.
Definition: gimp.h:35
QImageIOHandler
uchar
quint8 uchar
Definition: dds.cpp:38
QImage
TILE_WIDTH
const uint TILE_WIDTH
Width of a tile in the XCF file.
Definition: gimp.h:34
QVector
XCFHandler::write
bool write(const QImage &image)
Definition: xcf.cpp:2387
XCFImageFormat
Definition: xcf.h:59
uint
quint32 uint
Definition: dds.cpp:36
Tiles
QVector< QVector< QImage > > Tiles
Definition: xcf.h:55
XCFImageFormat::readXCF
bool readXCF(QIODevice *device, QImage *image)
Definition: xcf.cpp:105
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:49 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KImgIO

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal