libpgf 6.14.12
PGF - Progressive Graphics File
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"
50#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//-------------------------------------------------------------------------------
92enum Orientation { LL=0, HL=1, LH=2, HH=3 };
93
98
99#pragma pack(1)
105 char magic[3];
106 UINT8 version;
107 // total: 4 Bytes
108};
109
115 UINT32 hSize;
116 // total: 8 Bytes
117};
118
123struct 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
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;
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
182 IOException() : error(NoError) {}
185 IOException(OSError err) : error(err) {}
186
187 OSError error;
188};
189
194struct 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__
219typedef INT32 DataT;
220#else
221typedef INT16 DataT;
222#endif
223
224typedef 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.
#define ImageModeUnknown
Definition: PGFplatform.h:119
void(* RefreshCB)(void *p)
Definition: PGFtypes.h:224
Orientation
Definition: PGFtypes.h:92
@ LL
Definition: PGFtypes.h:92
@ HL
Definition: PGFtypes.h:92
@ LH
Definition: PGFtypes.h:92
@ HH
Definition: PGFtypes.h:92
#define ColorTableLen
size of color lookup table (clut)
Definition: PGFtypes.h:60
#define RLblockSizeLen
block size length (< 16): ld(BufferSize) < RLblockSizeLen <= 2*ld(BufferSize)
Definition: PGFtypes.h:78
INT32 DataT
Definition: PGFtypes.h:219
PGF exception.
Definition: PGFtypes.h:180
OSError error
operating system error code
Definition: PGFtypes.h:187
IOException(OSError err)
Definition: PGFtypes.h:185
IOException()
Standard constructor.
Definition: PGFtypes.h:182
PGF header.
Definition: PGFtypes.h:123
UINT8 mode
image mode according to Adobe's image modes
Definition: PGFtypes.h:131
UINT8 reserved2
not used
Definition: PGFtypes.h:133
UINT8 reserved1
Definition: PGFtypes.h:133
UINT32 height
image height in pixels
Definition: PGFtypes.h:126
UINT32 width
image width in pixels
Definition: PGFtypes.h:125
UINT8 nLevels
number of DWT levels
Definition: PGFtypes.h:127
UINT8 channels
number of channels
Definition: PGFtypes.h:130
UINT8 usedBitsPerChannel
number of used bits per channel in 16- and 32-bit per channel modes
Definition: PGFtypes.h:132
UINT8 quality
quantization parameter: 0=lossless, 4=standard, 6=poor quality
Definition: PGFtypes.h:128
PGFHeader()
Definition: PGFtypes.h:124
UINT8 bpp
bits per pixel
Definition: PGFtypes.h:129
PGF identification and version.
Definition: PGFtypes.h:104
char magic[3]
PGF identification = "PGF".
Definition: PGFtypes.h:105
UINT8 version
PGF version.
Definition: PGFtypes.h:106
Optional PGF post-header.
Definition: PGFtypes.h:141
UINT32 userDataLen
user data size in bytes
Definition: PGFtypes.h:144
RGBQUAD clut[ColorTableLen]
color table for indexed color images
Definition: PGFtypes.h:142
UINT8 * userData
user data of size userDataLen
Definition: PGFtypes.h:143
PGF pre-header.
Definition: PGFtypes.h:114
UINT32 hSize
total size of PGFHeader, [ColorTable], and [UserData] in bytes
Definition: PGFtypes.h:115
Rectangle.
Definition: PGFtypes.h:194
UINT32 Height() const
Definition: PGFtypes.h:207
bool IsInside(UINT32 x, UINT32 y) const
Definition: PGFtypes.h:213
PGFRect()
Standard constructor.
Definition: PGFtypes.h:196
UINT32 Width() const
Definition: PGFtypes.h:205
UINT32 top
Definition: PGFtypes.h:215
UINT32 bottom
Definition: PGFtypes.h:215
UINT32 right
Definition: PGFtypes.h:215
PGFRect(UINT32 x, UINT32 y, UINT32 width, UINT32 height)
Definition: PGFtypes.h:202
UINT32 left
Definition: PGFtypes.h:215
Named ROI block header (part of the union)
Definition: PGFtypes.h:162
UINT16 tileEnd
1: last part of a tile
Definition: PGFtypes.h:168
UINT16 bufferSize
number of uncoded UINT32 values in a block
Definition: PGFtypes.h:167
Block header used with ROI coding scheme
Definition: PGFtypes.h:151
struct ROIBlockHeader::RBH rbh
ROI block header.
UINT16 val
Definition: PGFtypes.h:160
ROIBlockHeader(UINT32 size, bool end)
Definition: PGFtypes.h:158
ROIBlockHeader(UINT16 v)
Definition: PGFtypes.h:154