DCMTK  Version 3.6.1 20120515
OFFIS DICOM Toolkit
Public Member Functions | Protected Member Functions | Protected Attributes
I2DBmpSource Class Reference

This is a I2DImgSource implementation that can parse BMP files and convert them into DICOM images. More...

+ Inheritance diagram for I2DBmpSource:

List of all members.

Public Member Functions

 I2DBmpSource ()
 Constructor, initializes member variables.
OFString inputFormat () const
 Returns format of input image.
OFCondition readPixelData (Uint16 &rows, Uint16 &cols, Uint16 &samplesPerPixel, OFString &photoMetrInt, Uint16 &bitsAlloc, Uint16 &bitsStored, Uint16 &highBit, Uint16 &pixelRepr, Uint16 &planConf, Uint16 &pixAspectH, Uint16 &pixAspectV, char *&pixData, Uint32 &length, E_TransferSyntax &ts)
 Extracts the raw BMP pixel data stream from a BMP file and returns some image information about this pixel data.
virtual OFCondition getLossyComprInfo (OFBool &srcEncodingLossy, OFString &) const
 After reading of pixel data, this function can be used for getting information about lossy compression parameters.
virtual ~I2DBmpSource ()
 Destructor, frees some memory.

Protected Member Functions

OFCondition openFile (const OFString &filename)
 Opens the BMP file specified by the given filename.
void closeFile ()
 Closes BMP file.
OFCondition readFileHeader (Uint32 &offset)
 Reads and checks the BMP file header.
OFCondition readBitmapHeader (Uint16 &width, Uint16 &height, Uint16 &bpp, OFBool &isTopDown, Uint16 &colors)
 Reads and checks the BMP bitmap header.
OFCondition readColorPalette (Uint16 colors, Uint32 *&palette)
 Read the color palette from the file.
OFCondition readBitmapData (const Uint16 width, const Uint16 height, const Uint16 bpp, const OFBool isTopDown, const Uint16 colors, const Uint32 *palette, char *&pixData, Uint32 &length)
 Read the bitmap data.
OFCondition parse24_32BppRow (const Uint8 *row, const Uint16 width, const int bpp, char *pixData) const
 Parse a single 24bpp or 32bpp row of bmp data.
OFCondition parse16BppRow (const Uint8 *row, const Uint16 width, char *pixData) const
 Parse a single 16bpp row of bmp data.
OFCondition parseIndexedColorRow (const Uint8 *row, const Uint16 width, const int bpp, const Uint16 colors, const Uint32 *palette, char *pixData) const
 Parse a single 1, 4 or 8bpp row of bmp data.
int readLong (Sint32 &result)
 Read 4 bytes from the byte stream and interpret it as a signed integer.
int readDWord (Uint32 &result)
 Read 4 bytes from the byte stream.
int readWord (Uint16 &result)
 Read 2 bytes from the byte stream.

Protected Attributes

OFFile bmpFile
 The BMP file, if opened.

Detailed Description

This is a I2DImgSource implementation that can parse BMP files and convert them into DICOM images.


Constructor & Destructor Documentation

Constructor, initializes member variables.

Returns:
none
virtual I2DBmpSource::~I2DBmpSource ( ) [virtual]

Destructor, frees some memory.

Returns:
none

Member Function Documentation

void I2DBmpSource::closeFile ( ) [protected]

Closes BMP file.

Returns:
none
virtual OFCondition I2DBmpSource::getLossyComprInfo ( OFBool &  srcEncodingLossy,
OFString  
) const [inline, virtual]

After reading of pixel data, this function can be used for getting information about lossy compression parameters.

Parameters:
srcEncodingLossy- [out] Denotes, whether the encoding of the pixel data read was lossy (OFtrue) or lossless (OFFalse)
srcLossyComprMethod- [out] Denotes the lossy compression method used in source if there is one (srcEncodingLossy = OFTrue). Should use defined terms of attribute Lossy Compression Method.
Returns:
EC_Normal if information is available, error otherwise

Implements I2DImgSource.

OFString I2DBmpSource::inputFormat ( ) const [virtual]

Returns format of input image.

For this class "BMP" is returned.

Returns:
Returns format of input image, i. e. "BMP".

Implements I2DImgSource.

OFCondition I2DBmpSource::openFile ( const OFString filename) [protected]

Opens the BMP file specified by the given filename.

Parameters:
filename- [in] The file to be opened
Returns:
EC_Normal, if successful, error otherwise
OFCondition I2DBmpSource::parse16BppRow ( const Uint8 *  row,
const Uint16  width,
char *  pixData 
) const [protected]

Parse a single 16bpp row of bmp data.

Parameters:
row- [in] The row of data to parse.
width- [in] The length in pixel of the row.
pixData- [out] The buffer to write the data to (in "RGB" format).
Returns:
EC_Normal, if successful, error otherwise
OFCondition I2DBmpSource::parse24_32BppRow ( const Uint8 *  row,
const Uint16  width,
const int  bpp,
char *  pixData 
) const [protected]

Parse a single 24bpp or 32bpp row of bmp data.

Parameters:
row- [in] The row of data to parse.
width- [in] The length in pixel of the row.
bpp- [in] The number of bits per pixel.
pixData- [out] The buffer to write the data to (in "RGB" format).
Returns:
EC_Normal, if successful, error otherwise
OFCondition I2DBmpSource::parseIndexedColorRow ( const Uint8 *  row,
const Uint16  width,
const int  bpp,
const Uint16  colors,
const Uint32 *  palette,
char *  pixData 
) const [protected]

Parse a single 1, 4 or 8bpp row of bmp data.

Parameters:
row- [in] The row of data to parse.
width- [in] The length in pixel of the row.
bpp- [in] The number of bits per pixel.
colors- [in] The number of entries in the color palette.
palette- [in] The color palette to use.
pixData- [out] The buffer to write the data to (in "RGB" format).
Returns:
EC_Normal, if successful, error otherwise
OFCondition I2DBmpSource::readBitmapData ( const Uint16  width,
const Uint16  height,
const Uint16  bpp,
const OFBool  isTopDown,
const Uint16  colors,
const Uint32 *  palette,
char *&  pixData,
Uint32 &  length 
) [protected]

Read the bitmap data.

This assumes the current read position is at the start of the image data.

Parameters:
width- [in] width of the image in pixel
height- [in] height of the image in pixel
bpp- [in] Image's bits per pixel.
isTopDown- [in] If true, this is a top down bitmap
colors- [in] Number of color palette entries
palette- [in] Color palette
pixData- [out] Image data
length- [out] Length of data
Returns:
EC_Normal, if successful, error otherwise
OFCondition I2DBmpSource::readBitmapHeader ( Uint16 &  width,
Uint16 &  height,
Uint16 &  bpp,
OFBool &  isTopDown,
Uint16 &  colors 
) [protected]

Reads and checks the BMP bitmap header.

After this function, the current read position is just after the header. That is, at the beginning of the color palette.

Parameters:
width- [out] width of the image in pixel
height- [out] height of the image in pixel
isTopDown- [out] OFTrue if this is a top down bitmap (height was read as negative value).OFFalse otherwise.
bpp- [out] bits per pixel of the image.
colors- [out] number of entries in color table.
Returns:
EC_Normal, if successful, error otherwise
OFCondition I2DBmpSource::readColorPalette ( Uint16  colors,
Uint32 *&  palette 
) [protected]

Read the color palette from the file.

Parameters:
colors- [in] number of colors to read
palette- [out] the read color palette is stored here
Returns:
EC_Normal, if successful, error otherwise
int I2DBmpSource::readDWord ( Uint32 &  result) [protected]

Read 4 bytes from the byte stream.

Parameters:
result- [out] The result
Returns:
0, if successful, EOF if rest of stream does not contain enough bytes
OFCondition I2DBmpSource::readFileHeader ( Uint32 &  offset) [protected]

Reads and checks the BMP file header.

Parameters:
offset- [out] Offset to the BMP data from beginning of file
Returns:
EC_Normal, if successful, error otherwise
int I2DBmpSource::readLong ( Sint32 &  result) [protected]

Read 4 bytes from the byte stream and interpret it as a signed integer.

Parameters:
result- [out] The result
Returns:
0, if successful, EOF if rest of stream does not contain enough bytes
OFCondition I2DBmpSource::readPixelData ( Uint16 &  rows,
Uint16 &  cols,
Uint16 &  samplesPerPixel,
OFString photoMetrInt,
Uint16 &  bitsAlloc,
Uint16 &  bitsStored,
Uint16 &  highBit,
Uint16 &  pixelRepr,
Uint16 &  planConf,
Uint16 &  pixAspectH,
Uint16 &  pixAspectV,
char *&  pixData,
Uint32 &  length,
E_TransferSyntax &  ts 
) [virtual]

Extracts the raw BMP pixel data stream from a BMP file and returns some image information about this pixel data.

Raw means that any header information is removed from the BMP stream. This function allocates memory for the pixel data returned to the user. The caller of this function is responsible for deleting the memory buffer

Parameters:
rows- [out] Rows of image
cols- [out] Columns of image
samplesPerPixel- [out] Number of components per pixel
photoMetrInt- [out] The DICOM color model used for the compressed data
bitsAlloc- [out] Bits Allocated for one sample
bitsStored- [out] Bits Stored, Number of bits actually stored within Bits Allocated
highBit- [out] High Bit, Highest stored in bit within Bits Allocated
pixelRepr- [out] Pixel Representation (0=unsigned, 1=signed)
planConf- [out] Planar Configuration
pixAspectH- [out] Horizontal value of pixel aspect ratio
pixAspectV- [out] Vertical value of pixel aspect ratio
pixData- [out] Pointer to the pixel data in BMP Interchange Format (but without APPx markers).
length- [out] Length of pixel data
ts- [out] The transfer syntax imposed by the imported pixel pixel data. This is necessary for the BMP importer that needs to report which TS must be used for the imported BMP data (ie. baseline, progressive, ...).
Returns:
EC_Normal, if successful, error otherwise

Implements I2DImgSource.

int I2DBmpSource::readWord ( Uint16 &  result) [protected]

Read 2 bytes from the byte stream.

Parameters:
result- [out] The result
Returns:
0, if successful, EOF if rest of stream does not contain enough bytes

The documentation for this class was generated from the following file:


Generated on Tue May 15 2012 for DCMTK Version 3.6.1 20120515 by Doxygen 1.7.5.1-20111027