libpgf  6.12.24
PGF - Progressive Graphics File
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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.12.24"
49 
50 #define PGFCodecVersionID 0x061224
51 
52 //-------------------------------------------------------------------------------
53 // Image constants
54 //-------------------------------------------------------------------------------
55 #define Magic "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 
102 
103 
104 struct PGFMagicVersion {
105  char magic[3];
106  UINT8 version;
107  // total: 4 Bytes
108 };
109 
114 struct PGFPreHeader : PGFMagicVersion {
115  UINT32 hSize;
116  // total: 8 Bytes
117 };
118 
123 struct PGFHeader {
125  UINT32 width;
126  UINT32 height;
127  UINT8 nLevels;
128  UINT8 quality;
129  UINT8 bpp;
130  UINT8 channels;
131  UINT8 mode;
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 
162  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