Scribus
Open source desktop publishing at your fingertips
PGFtypes.h
Go to the documentation of this file.
1 /*
2  * The Progressive Graphics File; http://www.libpgf.org
3  *
4  * $Date: 2007-06-11 10:56:17 +0200 (Mo, 11 Jun 2007) $
5  * $Revision: 299 $
6  *
7  * This file Copyright (C) 2006 xeraina GmbH, Switzerland
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  */
23 
28 
29 #ifndef PGF_PGFTYPES_H
30 #define PGF_PGFTYPES_H
31 
32 #include "PGFplatform.h"
33 
34 //-------------------------------------------------------------------------------
35 // Constraints
36 //-------------------------------------------------------------------------------
37 // BufferSize <= UINT16_MAX
38 
39 //-------------------------------------------------------------------------------
40 // Codec versions
41 //
42 // Version 2: modified data structure PGFHeader (backward compatibility assured)
43 // Version 4: DataT: INT32 instead of INT16, allows 31 bit per pixel and channel (backward compatibility assured)
44 // Version 5: ROI, new block-reordering scheme (backward compatibility assured)
45 // Version 6: modified data structure PGFPreHeader: hSize (header size) is now a UINT32 instead of a UINT16 (backward compatibility assured)
46 //
47 //-------------------------------------------------------------------------------
48 #define PGFCodecVersion "6.14.12"
49 #define PGFCodecVersionID 0x061412
51 
52 //-------------------------------------------------------------------------------
53 // Image constants
54 //-------------------------------------------------------------------------------
55 #define PGFMagic "PGF"
56 #define MaxLevel 30
57 #define NSubbands 4
58 #define MaxChannels 8
59 #define DownsampleThreshold 3
60 #define ColorTableLen 256
61 // version flags
62 #define Version2 2
63 #define PGF32 4
64 #define PGFROI 8
65 #define Version5 16
66 #define Version6 32
67 // version numbers
68 #ifdef __PGF32SUPPORT__
69 #define PGFVersion (Version2 | PGF32 | Version5 | Version6)
70 #else
71 #define PGFVersion (Version2 | Version5 | Version6)
72 #endif
73 
74 //-------------------------------------------------------------------------------
75 // Coder constants
76 //-------------------------------------------------------------------------------
77 #define BufferSize 16384
78 #define RLblockSizeLen 15
79 #define LinBlockSize 8
80 #define InterBlockSize 4
81 #ifdef __PGF32SUPPORT__
82  #define MaxBitPlanes 31
83 #else
84  #define MaxBitPlanes 15
85 #endif
86 #define MaxBitPlanesLog 5
87 #define MaxQuality MaxBitPlanes
88 
89 //-------------------------------------------------------------------------------
90 // Types
91 //-------------------------------------------------------------------------------
92 enum Orientation { LL=0, HL=1, LH=2, HH=3 };
93 
98 
99 #pragma pack(1)
100 struct PGFMagicVersion {
105  char magic[3];
106  UINT8 version;
107  // total: 4 Bytes
108 };
109 
115  UINT32 hSize;
116  // total: 8 Bytes
117 };
118 
123 struct PGFHeader {
124  PGFHeader() : width(0), height(0), nLevels(0), quality(0), bpp(0), channels(0), mode(ImageModeUnknown), usedBitsPerChannel(0), reserved1(0), reserved2(0) {}
125  UINT32 width;
126  UINT32 height;
127  UINT8 nLevels;
128  UINT8 quality;
129  UINT8 bpp;
130  UINT8 channels;
131  UINT8 mode;
133  UINT8 reserved1, reserved2;
134  // total: 16 Bytes
135 };
136 
142  RGBQUAD clut[ColorTableLen];
143  UINT8 *userData;
144  UINT32 userDataLen;
145 };
146 
154  ROIBlockHeader(UINT16 v) { val = v; }
158  ROIBlockHeader(UINT32 size, bool end) { ASSERT(size < (1 << RLblockSizeLen)); rbh.bufferSize = size; rbh.tileEnd = end; }
159 
160  UINT16 val;
161  struct RBH {
163 #ifdef PGF_USE_BIG_ENDIAN
164  UINT16 tileEnd : 1;
165  UINT16 bufferSize: RLblockSizeLen;
166 #else
168  UINT16 tileEnd : 1;
169 #endif // PGF_USE_BIG_ENDIAN
170  } rbh;
171  // total: 2 Bytes
172 };
173 
174 #pragma pack()
175 
180 struct IOException {
182  IOException() : error(NoError) {}
185  IOException(OSError err) : error(err) {}
186 
187  OSError error;
188 };
189 
194 struct PGFRect {
196  PGFRect() : left(0), top(0), right(0), bottom(0) {}
202  PGFRect(UINT32 x, UINT32 y, UINT32 width, UINT32 height) : left(x), top(y), right(x + width), bottom(y + height) {}
203 
205  UINT32 Width() const { return right - left; }
207  UINT32 Height() const { return bottom - top; }
208 
213  bool IsInside(UINT32 x, UINT32 y) const { return (x >= left && x < right && y >= top && y < bottom); }
214 
215  UINT32 left, top, right, bottom;
216 };
217 
218 #ifdef __PGF32SUPPORT__
219 typedef INT32 DataT;
220 #else
221 typedef INT16 DataT;
222 #endif
223 
224 typedef void (*RefreshCB)(void *p);
225 
226 //-------------------------------------------------------------------------------
227 // Image constants
228 //-------------------------------------------------------------------------------
229 #define MagicVersionSize sizeof(PGFMagicVersion)
230 #define PreHeaderSize sizeof(PGFPreHeader)
231 #define HeaderSize sizeof(PGFHeader)
232 #define ColorTableSize ColorTableLen*sizeof(RGBQUAD)
233 #define DataTSize sizeof(DataT)
234 
235 #endif //PGF_PGFTYPES_H
PGF platform specific definitions.
PGF identification and version.
Definition: PGFtypes.h:104
UINT8 nLevels
number of DWT levels
Definition: PGFtypes.h:127
ROIBlockHeader(UINT32 size, bool end)
Definition: PGFtypes.h:158
PGFRect()
Standard constructor.
Definition: PGFtypes.h:196
#define ColorTableLen
size of color lookup table (clut)
Definition: PGFtypes.h:60
bool IsInside(UINT32 x, UINT32 y) const
Definition: PGFtypes.h:213
UINT32 height
image height in pixels
Definition: PGFtypes.h:126
UINT32 userDataLen
user data size in bytes
Definition: PGFtypes.h:144
UINT8 bpp
bits per pixel
Definition: PGFtypes.h:129
UINT8 * userData
user data of size userDataLen
Definition: PGFtypes.h:143
Named ROI block header (part of the union)
Definition: PGFtypes.h:162
UINT16 val
Definition: PGFtypes.h:160
PGF header.
Definition: PGFtypes.h:123
struct ROIBlockHeader::RBH rbh
ROI block header.
#define RLblockSizeLen
block size length (< 16): ld(BufferSize) < RLblockSizeLen <= 2*ld(BufferSize)
Definition: PGFtypes.h:78
OSError error
operating system error code
Definition: PGFtypes.h:187
IOException()
Standard constructor.
Definition: PGFtypes.h:182
UINT8 quality
quantization parameter: 0=lossless, 4=standard, 6=poor quality
Definition: PGFtypes.h:128
IOException(OSError err)
Definition: PGFtypes.h:185
char magic[3]
PGF identification = "PGF".
Definition: PGFtypes.h:105
PGF exception.
Definition: PGFtypes.h:180
UINT8 mode
image mode according to Adobe's image modes
Definition: PGFtypes.h:131
Block header used with ROI coding scheme.
Definition: PGFtypes.h:151
UINT8 channels
number of channels
Definition: PGFtypes.h:130
RGBQUAD clut[ColorTableLen]
color table for indexed color images
Definition: PGFtypes.h:142
UINT8 usedBitsPerChannel
number of used bits per channel in 16- and 32-bit per channel modes
Definition: PGFtypes.h:132
UINT8 version
PGF version.
Definition: PGFtypes.h:106
UINT16 bufferSize
number of uncoded UINT32 values in a block
Definition: PGFtypes.h:167
PGF pre-header.
Definition: PGFtypes.h:114
UINT16 tileEnd
1: last part of a tile
Definition: PGFtypes.h:168
UINT8 reserved2
not used
Definition: PGFtypes.h:133
Optional PGF post-header.
Definition: PGFtypes.h:141
ROIBlockHeader(UINT16 v)
Definition: PGFtypes.h:154
UINT32 hSize
total size of PGFHeader, [ColorTable], and [UserData] in bytes
Definition: PGFtypes.h:115
UINT32 Width() const
Definition: PGFtypes.h:205
UINT32 width
image width in pixels
Definition: PGFtypes.h:125
UINT32 Height() const
Definition: PGFtypes.h:207
PGFRect(UINT32 x, UINT32 y, UINT32 width, UINT32 height)
Definition: PGFtypes.h:202
Rectangle.
Definition: PGFtypes.h:194