00001 /* 00002 * 00003 * Copyright (C) 2009-2010, OFFIS e.V. 00004 * All rights reserved. See COPYRIGHT file for details. 00005 * 00006 * This software and supporting documentation were developed by 00007 * 00008 * OFFIS e.V. 00009 * R&D Division Health 00010 * Escherweg 2 00011 * D-26121 Oldenburg, Germany 00012 * 00013 * 00014 * Module: dcmdata 00015 * 00016 * Author: Uli Schlachter 00017 * 00018 * Purpose: Class to extract pixel data and meta information from BMP file 00019 * 00020 * Last Update: $Author: uli $ 00021 * Update Date: $Date: 2010-11-15 13:58:43 $ 00022 * CVS/RCS Revision: $Revision: 1.9 $ 00023 * Status: $State: Exp $ 00024 * 00025 * CVS/RCS Log at end of file 00026 * 00027 */ 00028 00029 #ifndef I2DBMPS_H 00030 #define I2DBMPS_H 00031 00032 #include "dcmtk/config/osconfig.h" 00033 #include "dcmtk/dcmdata/libi2d/i2dimgs.h" 00034 #include "dcmtk/ofstd/offile.h" 00035 00039 class I2DBmpSource : public I2DImgSource 00040 { 00041 00042 public: 00043 00047 I2DBmpSource(); 00048 00052 OFString inputFormat() const; 00053 00077 OFCondition readPixelData( Uint16& rows, 00078 Uint16& cols, 00079 Uint16& samplesPerPixel, 00080 OFString& photoMetrInt, 00081 Uint16& bitsAlloc, 00082 Uint16& bitsStored, 00083 Uint16& highBit, 00084 Uint16& pixelRepr, 00085 Uint16& planConf, 00086 Uint16& pixAspectH, 00087 Uint16& pixAspectV, 00088 char*& pixData, 00089 Uint32& length, 00090 E_TransferSyntax& ts); 00091 00101 virtual OFCondition getLossyComprInfo(OFBool& srcEncodingLossy, 00102 OFString& /* srcLossyComprMethod */) const 00103 { 00104 srcEncodingLossy = OFFalse; 00105 return EC_Normal; 00106 } 00107 00111 virtual ~I2DBmpSource(); 00112 00113 protected: 00114 00119 OFCondition openFile(const OFString& filename); 00120 00124 void closeFile(); 00125 00130 OFCondition readFileHeader(Uint32 &offset); 00131 00143 OFCondition readBitmapHeader(Uint16 &width /*out*/, 00144 Uint16 &height /*out*/, 00145 Uint16 &bpp /*out*/, 00146 OFBool &isTopDown /*out*/, 00147 Uint16 &colors /*out*/); 00148 00154 OFCondition readColorPalette(Uint16 colors, 00155 Uint32*& palette); 00156 00169 OFCondition readBitmapData(const Uint16 width, 00170 const Uint16 height, 00171 const Uint16 bpp, 00172 const OFBool isTopDown, 00173 const Uint16 colors, 00174 const Uint32* palette, 00175 char*& pixData /*out*/, 00176 Uint32& length /*out*/); 00177 00185 OFCondition parse24_32BppRow(const Uint8 *row, 00186 const Uint16 width, 00187 const int bpp, 00188 char *pixData /*out*/) const; 00189 00196 OFCondition parse16BppRow(const Uint8 *row, 00197 const Uint16 width, 00198 char *pixData /*out*/) const; 00199 00209 OFCondition parseIndexedColorRow(const Uint8 *row, 00210 const Uint16 width, 00211 const int bpp, 00212 const Uint16 colors, 00213 const Uint32* palette, 00214 char *pixData /*out*/) const; 00215 00220 int readLong(Sint32& result); 00221 00226 int readDWord(Uint32& result); 00227 00232 int readWord(Uint16& result); 00233 00235 OFFile bmpFile; 00236 }; 00237 00238 #endif // #ifndef I2DBMPS_H 00239 00240 /* 00241 * CVS/RCS Log: 00242 * $Log: i2dbmps.h,v $ 00243 * Revision 1.9 2010-11-15 13:58:43 uli 00244 * Fixed some errors in doxygen comments. 00245 * 00246 * Revision 1.8 2010-10-14 13:15:46 joergr 00247 * Updated copyright header. Added reference to COPYRIGHT file. 00248 * 00249 * Revision 1.7 2010-10-01 10:21:05 uli 00250 * Fixed most compiler warnings from -Wall -Wextra -pedantic in dcmdata. 00251 * 00252 * Revision 1.6 2010-06-01 10:33:53 uli 00253 * Added support for indexed-color BMP images (bit depths 1, 4 and 8). 00254 * 00255 * Revision 1.5 2010-05-25 12:40:06 uli 00256 * Added support for 16bpp BMP images to libi2d 00257 * 00258 * Revision 1.4 2010-05-21 14:43:07 uli 00259 * Added support for 32bpp BMP images to libi2d. 00260 * 00261 * Revision 1.3 2009-11-04 09:58:08 uli 00262 * Switched to logging mechanism provided by the "new" oflog module 00263 * 00264 * Revision 1.2 2009-09-30 08:05:25 uli 00265 * Stop including dctk.h in libi2d's header files. 00266 * 00267 * Revision 1.1 2009-07-16 14:25:28 onken 00268 * Added img2dcm input plugin for the BMP graphics format (at the moment only 00269 * support for 24 Bit RGB). 00270 * 00271 * 00272 */ 00273