libpgf  6.11.42
PGF - Progressive Graphics File
PGFtypes.h
Go to the documentation of this file.
00001 /*
00002  * The Progressive Graphics File; http://www.libpgf.org
00003  * 
00004  * $Date: 2007-06-11 10:56:17 +0200 (Mo, 11 Jun 2007) $
00005  * $Revision: 299 $
00006  * 
00007  * This file Copyright (C) 2006 xeraina GmbH, Switzerland
00008  * 
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
00011  * as published by the Free Software Foundation; either version 2.1
00012  * of the License, or (at your option) any later version.
00013  * 
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  * 
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022  */
00023 
00028 
00029 #ifndef PGF_PGFTYPES_H
00030 #define PGF_PGFTYPES_H
00031 
00032 #include "PGFplatform.h"
00033 
00034 //-------------------------------------------------------------------------------
00035 //      Constraints
00036 //-------------------------------------------------------------------------------
00037 // BufferSize <= UINT16_MAX
00038 
00039 //-------------------------------------------------------------------------------
00040 //      Codec versions
00041 //
00042 // Version 2:   modified data structure PGFHeader (backward compatibility assured)
00043 // Version 3:   DataT: INT32 instead of INT16, allows 31 bit per pixel and channel (backward compatibility assured)
00044 // Version 5:   ROI, new block-reordering scheme (backward compatibility assured)
00045 // Version 6:   modified data structure PGFPreHeader: hSize (header size) is now a UINT32 instead of a UINT16 (backward compatibility assured)
00046 //
00047 //-------------------------------------------------------------------------------
00048 #define PGFCodecVersion         "6.11.42"                       ///< Major number
00049 
00050 #define PGFCodecVersionID   0x061142            ///< Codec version ID to use for API check in client implementation
00051 
00052 //-------------------------------------------------------------------------------
00053 //      Image constants
00054 //-------------------------------------------------------------------------------
00055 #define Magic                           "PGF"                           ///< PGF identification
00056 #define MaxLevel                        30                                      ///< maximum number of transform levels
00057 #define NSubbands                       4                                       ///< number of subbands per level
00058 #define MaxChannels                     8                                       ///< maximum number of (color) channels
00059 #define DownsampleThreshold 3                                   ///< if quality is larger than this threshold than downsampling is used
00060 #define DefaultBGColor          255                                     ///< default background color is white
00061 #define ColorTableLen           256                                     ///< size of color lookup table (clut)
00062 // version flags
00063 #define Version2                        2                                       ///< data structure PGFHeader of major version 2
00064 #define PGF32                           4                                       ///< 32 bit values are used -> allows at maximum 31 bits, otherwise 16 bit values are used -> allows at maximum 15 bits
00065 #define PGFROI                          8                                       ///< supports Regions Of Interest
00066 #define Version5                        16                                      ///< new coding scheme since major version 5
00067 #define Version6                        32                                      ///< new HeaderSize: 32 bits instead of 16 bits 
00068 // version numbers
00069 #ifdef __PGF32SUPPORT__
00070 #define PGFVersion                      (Version2 | PGF32 | Version5 | Version6)        ///< current standard version
00071 #else
00072 #define PGFVersion                      (Version2 |         Version5 | Version6)        ///< current standard version
00073 #endif
00074 
00075 //-------------------------------------------------------------------------------
00076 //      Coder constants
00077 //-------------------------------------------------------------------------------
00078 #define BufferSize                      16384                           ///< must be a multiple of WordWidth
00079 #define RLblockSizeLen          15                                      ///< block size length (< 16): ld(BufferSize) < RLblockSizeLen <= 2*ld(BufferSize)
00080 #define LinBlockSize            8                                       ///< side length of a coefficient block in a HH or LL subband
00081 #define InterBlockSize          4                                       ///< side length of a coefficient block in a HL or LH subband
00082 #ifdef __PGF32SUPPORT__
00083         #define MaxBitPlanes    31                                      ///< maximum number of bit planes of m_value: 32 minus sign bit
00084 #else
00085         #define MaxBitPlanes    15                                      ///< maximum number of bit planes of m_value: 16 minus sign bit
00086 #endif
00087 #define MaxBitPlanesLog         5                                       ///< number of bits to code the maximum number of bit planes (in 32 or 16 bit mode)
00088 #define MaxQuality                      MaxBitPlanes            ///< maximum quality
00089 
00090 //-------------------------------------------------------------------------------
00091 // Types
00092 //-------------------------------------------------------------------------------
00093 enum Orientation { LL=0, HL=1, LH=2, HH=3 };
00094 
00099 
00100 #pragma pack(1)
00101 
00102 
00103 
00104 
00105 struct PGFMagicVersion {
00106         char magic[3];                          
00107         UINT8 version;                          
00108         // total: 4 Bytes
00109 };
00110 
00115 struct PGFPreHeader : PGFMagicVersion {
00116         UINT32 hSize;                           
00117         // total: 8 Bytes
00118 };
00119 
00124 struct PGFHeader {
00125         PGFHeader() : width(0), height(0), nLevels(0), quality(0), bpp(0), channels(0), mode(ImageModeUnknown), usedBitsPerChannel(0), reserved1(0), reserved2(0) {}
00126         UINT32 width;                           
00127         UINT32 height;                          
00128         UINT8 nLevels;                          
00129         UINT8 quality;                          
00130         UINT8 bpp;                                      
00131         UINT8 channels;                         
00132         UINT8 mode;                                     
00133         UINT8 usedBitsPerChannel;       
00134         UINT8 reserved1, reserved2;     
00135         // total: 16 Bytes
00136 };
00137 
00142 struct PGFPostHeader {
00143         RGBQUAD clut[ColorTableLen];
00144         UINT8 *userData;                        
00145         UINT32 userDataLen;                     
00146 };
00147 
00152 union ROIBlockHeader {
00155         ROIBlockHeader(UINT16 v) { val = v; }
00159         ROIBlockHeader(UINT32 size, bool end)   { ASSERT(size < (1 << RLblockSizeLen)); rbh.bufferSize = size; rbh.tileEnd = end; }
00160         
00161         UINT16 val; 
00162 
00163         struct RBH {
00164 #ifdef PGF_USE_BIG_ENDIAN
00165                 UINT16 tileEnd   :                              1;      
00166                 UINT16 bufferSize: RLblockSizeLen;      
00167 #else
00168                 UINT16 bufferSize: RLblockSizeLen;      
00169                 UINT16 tileEnd   :                              1;      
00170 #endif // PGF_USE_BIG_ENDIAN
00171         } rbh;  
00172         // total: 2 Bytes
00173 };
00174 
00175 #pragma pack()
00176 
00181 struct IOException {
00183         IOException() : error(NoError) {}
00186         IOException(OSError err) : error(err) {}
00187 
00188         OSError error;                          
00189 };
00190 
00195 struct PGFRect {
00197         PGFRect() : left(0), top(0), right(0), bottom(0) {}
00203         PGFRect(UINT32 x, UINT32 y, UINT32 width, UINT32 height) : left(x), top(y), right(x + width), bottom(y + height) {}
00204 
00206         UINT32 Width() const                                    { return right - left; }
00208         UINT32 Height() const                                   { return bottom - top; }
00209         
00214         bool IsInside(UINT32 x, UINT32 y) const { return (x >= left && x < right && y >= top && y < bottom); }
00215 
00216         UINT32 left, top, right, bottom;
00217 };
00218 
00219 #ifdef __PGF32SUPPORT__
00220 typedef INT32 DataT;
00221 #else
00222 typedef INT16 DataT;
00223 #endif
00224 
00225 typedef void (*RefreshCB)(void *p);
00226 
00227 //-------------------------------------------------------------------------------
00228 // Image constants
00229 //-------------------------------------------------------------------------------
00230 #define MagicVersionSize        sizeof(PGFMagicVersion)
00231 #define PreHeaderSize           sizeof(PGFPreHeader)
00232 #define HeaderSize                      sizeof(PGFHeader)
00233 #define ColorTableSize          ColorTableLen*sizeof(RGBQUAD)
00234 #define DataTSize                       sizeof(DataT)
00235 
00236 #endif //PGF_PGFTYPES_H
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines