Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __IBMP_H__
00017 #define __IBMP_H__
00018
00019 #include "imagen.h"
00020
00021 #ifdef IMAGEN_BMP
00022
00023 #include "iAbstractImage.h"
00024
00025 namespace imagen
00026 {
00028
00046 class iBMP : public iAbstractImage
00047 {
00048 private:
00049 #pragma pack(1)
00050
00051 struct BITMAPFILEHEADER
00052 {
00053 BITMAPFILEHEADER();
00054 void clear();
00055
00056 iWORD FileType;
00057 iDWORD FileSize;
00058 iWORD Reserved1;
00059 iWORD Reserved2;
00060 iDWORD BitmapOffset;
00061 };
00062
00064 struct BITMAPCOREHEADER
00065 {
00066 BITMAPCOREHEADER();
00067 void clear();
00068
00069 iDWORD Size;
00070 iWORD Width;
00071 iWORD Height;
00072 iWORD Planes;
00073 iWORD BitsPerPixel;
00074 };
00075
00077 struct BITMAPINFOHEADER
00078 {
00079 BITMAPINFOHEADER();
00080 void clear();
00081
00082 iDWORD Size;
00083 iLONG Width;
00084 iLONG Height;
00085 iWORD Planes;
00086 iWORD BitsPerPixel;
00087 iDWORD Compression;
00088 iDWORD SizeOfBitmap;
00089 iLONG XResolution;
00090 iLONG YResolution;
00091 iDWORD ColorsUsed;
00092 iDWORD ColorsImportant;
00093 };
00094
00096 struct BITMAPV4HEADER : BITMAPINFOHEADER
00097 {
00098 BITMAPV4HEADER();
00099 void clear();
00100
00101 iDWORD RedMask;
00102 iDWORD GreenMask;
00103 iDWORD BlueMask;
00104 iDWORD AlphaMask;
00105 iDWORD CSType;
00106 iLONG RedX;
00107 iLONG RedY;
00108 iLONG RedZ;
00109 iLONG GreenX;
00110 iLONG GreenY;
00111 iLONG GreenZ;
00112 iLONG BlueX;
00113 iLONG BlueY;
00114 iLONG BlueZ;
00115 iDWORD GammaRed;
00116 iDWORD GammaGreen;
00117 iDWORD GammaBlue;
00118 };
00119
00121 struct BITMAPV5HEADER : BITMAPV4HEADER
00122 {
00123 BITMAPV5HEADER();
00124 void clear();
00125
00126 iDWORD Intent;
00127 iDWORD ProfileData;
00128 iDWORD ProfileSize;
00129 iDWORD Reserved;
00130 };
00131 #pragma pack()
00132
00133 public:
00134 enum BMPCompressFmt
00135 {
00136 BI_RGB = 0,
00137 BI_RLE8 = 1,
00138 BI_RLE4 = 2,
00139 BI_BITFIELDS = 3,
00140 BI_JPEG = 4,
00141 BI_PNG = 5
00142 };
00143
00144 enum BMPRenderingIntent
00145 {
00146 RI_COLORIMETRIC = 0,
00147 RI_BUSINESS = 1,
00148 RI_GRAPHICS = 2,
00149 RI_IMAGES = 3
00150 };
00151
00152 enum BMPColorSpace
00153 {
00154 CS_CALIBRATED_RGB = 0,
00155 CS_sRGB = 1,
00156 CS_CMYK = 2
00157 };
00158
00159 public:
00161 iBMP();
00162
00164
00165 iBMP( const iBMP &img );
00166
00168 iBMP( const iAbstractImage &img );
00169
00171
00175 iBMP( int w, int h, iImageFormat f );
00176
00178
00180 iBMP( Iubyte *d, int w, int h, iImageFormat f, int b );
00181
00183
00184 iBMP( const char *filename );
00185
00187
00188 iBMP( Iubyte *buf, int len );
00189
00191
00192 iBMP( iDataStream *s );
00193
00195 ~iBMP();
00196
00197 void clear();
00198
00199 bool isFormatSupported( iImageFormat fmt ) const;
00200
00201 static bool isValid( iDataStream *s );
00202
00203 iBMP &operator=( const iBMP &img );
00204
00205 iBMP &operator=( const iAbstractImage &img );
00206
00207 protected:
00208 void init();
00209 bool loadImage();
00210 bool saveImage();
00211
00212 private:
00213 bool readFileHeader();
00214 bool readBitmapHeader();
00215 bool validateHeader();
00216 bool readImageData();
00217
00218 bool readColTable();
00219
00220 bool writeFileHeader();
00221 bool writeBitmapHeader();
00222 bool writeImageData();
00223
00224 bool writeColTable();
00225
00226 private:
00227 BITMAPFILEHEADER fileheader;
00228 int bmpbits;
00229 };
00230 }
00231
00232 #endif // IMAGEN_BMP
00233
00234 #endif // __IBMP_H__