DCMTK  Version 3.6.1 20120515
OFFIS DICOM Toolkit
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
I2DJpegSource Class Reference
+ Inheritance diagram for I2DJpegSource:

List of all members.

Public Member Functions

 I2DJpegSource ()
 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 JPEG pixel data stream from a JPEG file and returns some image information about this pixel data.
OFCondition getLossyComprInfo (OFBool &srcEncodingLossy, OFString &srcLossyComprMethod) const
void setExtSeqSupport (const OFBool enabled)
 Enable/Disable support for Extended Sequential JPEG Coding.
void setProgrSupport (const OFBool enabled)
 Enable/Disable support for Progressive JPEG Coding.
void setInsistOnJFIF (const OFBool enabled)
 If enabled, conversion will only take place if JFIF data could be found and evaluated.
void setKeepAPPn (const OFBool enabled)
 If enabled, APPn markers (except JFIF!) are also copied to the output file.
 ~I2DJpegSource ()
 Destructor, frees some memory.

Static Public Member Functions

static OFString jpegMarkerToString (const E_JPGMARKER &marker)
 Returns a string representation of a JPEG marker code.

Protected Member Functions

OFCondition openFile (const OFString &filename)
 Opens the JPEG file specified by the given filename.
void closeFile ()
 Closes JPEG file.
OFCondition createJPEGFileMap ()
 Function that scans a JPEG file and creates a "file map" which includes all JPEG markes and their byte positions in the file.
void debugDumpJPEGFileMap () const
 Dump the internal JPEG file map to a given stream.
OFCondition getSOFImageParameters (const JPEGFileMapEntry &entry, Uint16 &imageWidth, Uint16 &imageHeight, Uint16 &samplesPerPixel, Uint16 &bitsPerSample)
 Get image parameters as found at given SOF marker of the JPEG image.
OFCondition getJFIFImageParameters (const JPEGFileMapEntry &entry, Uint16 &jfifVersion, Uint16 &pixelAspectH, Uint16 &pixelAspectV, Uint16 &unit)
 Get JPEG parameters as found at given JFIF marker of the JPEG image.
OFCondition isJPEGEncodingSupported (const E_JPGMARKER &jpegEncoding) const
 Check, whether a given JPEG image marker (SOFn) is supported by this plugin.
OFCondition extractRawJPEGStream (char *&pixelData, Uint32 &pixLength)
 Extract raw JPEG stream (i.e.
OFCondition copyJPEGStream (char *&pixelData, Uint32 &pixLength)
 Copies JPEG stream (with APPn markers, excluding JFIF) from JPEG file.
OFCondition skipVariable ()
 Skips one marker while scanning through the JPEG file stream.
OFCondition firstMarker (E_JPGMARKER &result)
 Tries to read the SOI marker.
OFCondition nextMarker (const OFBool &lastWasSOSMarker, E_JPGMARKER &result)
 Tries to find the next JPEG marker in underlying file stream.
int read2Bytes (Uint16 &result)
 Read 2 bytes from the byte stream.
int read1Byte (Uint8 &result)
 Read 1 byte from the byte stream.
void clearMap ()
 Deletes internal JPEG file map and frees memory.

Static Protected Member Functions

static E_TransferSyntax associatedTS (const E_JPGMARKER &jpegEncoding)
 Returns if possible the DICOM transfer syntax matching the coding of the JPEG data.
static OFBool isRSTMarker (const E_JPGMARKER &jpegEncoding)
 Returns true if marker is one of the RST0 to RST7 markers.
static OFBool isSOFMarker (const E_JPGMARKER &jpegEncoding)
 Returns true if marker is one of the SOF0 to SOF15 markers.

Protected Attributes

OFList< JPEGFileMapEntry * > m_jpegFileMap
 JPEG file map. This map includes all JPEG markers and their byte positions in the JPEG file.
OFFile jpegFile
 The JPEG file, if opened.
OFBool m_disableProgrTs
 If true, JPEGs with progressive coding are not supported.
OFBool m_disableExtSeqTs
 If true, JPEGs with extended sequential coding are not supported.
OFBool m_insistOnJFIF
 If true, conversion will only work if JFIF header can be found.
OFBool m_keepAPPn
 If true, APPn markers (except JFIF!) are also copied to the output file.
OFBool m_lossyCompressed
 After reading pixel data, this denotes whether the source data is already lossy compressed.

Constructor & Destructor Documentation

Constructor, initializes member variables.

Returns:
none

Destructor, frees some memory.

Returns:
none

Member Function Documentation

static E_TransferSyntax I2DJpegSource::associatedTS ( const E_JPGMARKER &  jpegEncoding) [static, protected]

Returns if possible the DICOM transfer syntax matching the coding of the JPEG data.

Parameters:
jpegEncoding- [in] Image marker that should be tested
Returns:
EC_Normal, marker is supported, error otherwise
void I2DJpegSource::clearMap ( ) [protected]

Deletes internal JPEG file map and frees memory.

Returns:
none
void I2DJpegSource::closeFile ( ) [protected]

Closes JPEG file.

Returns:
A string representation of the marker
OFCondition I2DJpegSource::copyJPEGStream ( char *&  pixelData,
Uint32 &  pixLength 
) [protected]

Copies JPEG stream (with APPn markers, excluding JFIF) from JPEG file.

Parameters:
pixelData- [out] The resulting JPEG stream
pixLength- [out] The length of the resulting stream
Returns:
EC_Normal, if successful, error otherwise

Function that scans a JPEG file and creates a "file map" which includes all JPEG markes and their byte positions in the file.

Returns:
EC_Normal, if successful, error otherwise
void I2DJpegSource::debugDumpJPEGFileMap ( ) const [protected]

Dump the internal JPEG file map to a given stream.

The file map lists JPEG markers and their position in the bitstream found in the JPEG file

Returns:
none
OFCondition I2DJpegSource::extractRawJPEGStream ( char *&  pixelData,
Uint32 &  pixLength 
) [protected]

Extract raw JPEG stream (i.e.

without APPn markers) from JPEG file.

Parameters:
pixelData- [out] The resulting JPEG stream
pixLength- [out] The length of the resulting stream
Returns:
EC_Normal, if successful, error otherwise
OFCondition I2DJpegSource::firstMarker ( E_JPGMARKER &  result) [protected]

Tries to read the SOI marker.

Parameters:
result- [out] The code of the SOI marker if successful (0xD8)
Returns:
EC_Normal, if successful, error otherwise
OFCondition I2DJpegSource::getJFIFImageParameters ( const JPEGFileMapEntry entry,
Uint16 &  jfifVersion,
Uint16 &  pixelAspectH,
Uint16 &  pixelAspectV,
Uint16 &  unit 
) [protected]

Get JPEG parameters as found at given JFIF marker of the JPEG image.

Parameters:
entry- [in] This specifies the marker and the byte position of the JFIF marker
jfifVersion- [out] The JFIF version of the JFIF data
pixelAspectH- [out] The horizontal pixel aspect ratio
pixelAspectV- [out] The vertical pixel aspect ratio
unit- [out] The contents of the pixel aspect ratio unit field
Returns:
EC_Normal, if successful, error otherwise
OFCondition I2DJpegSource::getSOFImageParameters ( const JPEGFileMapEntry entry,
Uint16 &  imageWidth,
Uint16 &  imageHeight,
Uint16 &  samplesPerPixel,
Uint16 &  bitsPerSample 
) [protected]

Get image parameters as found at given SOF marker of the JPEG image.

Parameters:
entry- [in] This specifies the marker and the byte position of the SOF marker
imageWidth- [out] The width of the image
imageHeight- [out] The height of the image
samplesPerPixel- [out] Number of components per pixel
bitsPerSample- [out] Nunber of bits per pixel component
Returns:
EC_Normal, if successful, error otherwise
OFString I2DJpegSource::inputFormat ( ) const [virtual]

Returns format of input image.

For this class "JPEG" is returned.

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

Implements I2DImgSource.

OFCondition I2DJpegSource::isJPEGEncodingSupported ( const E_JPGMARKER &  jpegEncoding) const [protected]

Check, whether a given JPEG image marker (SOFn) is supported by this plugin.

Parameters:
jpegEncoding- [in] Image marker that should be tested
Returns:
EC_Normal, marker is supported, error otherwise
static OFBool I2DJpegSource::isRSTMarker ( const E_JPGMARKER &  jpegEncoding) [static, protected]

Returns true if marker is one of the RST0 to RST7 markers.

Parameters:
jpegEncoding- [in] Image marker that should be tested
Returns:
OFTrue, if marker is RST0 to RST7, OFFalse otherwise
static OFBool I2DJpegSource::isSOFMarker ( const E_JPGMARKER &  jpegEncoding) [static, protected]

Returns true if marker is one of the SOF0 to SOF15 markers.

Parameters:
jpegEncoding- [in] Image marker that should be tested
Returns:
OFTrue, if marker is SOF0 to SOF15, OFFalse otherwise
static OFString I2DJpegSource::jpegMarkerToString ( const E_JPGMARKER &  marker) [static]

Returns a string representation of a JPEG marker code.

Parameters:
marker- [in] The marker to be converted
Returns:
A string representation of the marker
OFCondition I2DJpegSource::nextMarker ( const OFBool &  lastWasSOSMarker,
E_JPGMARKER &  result 
) [protected]

Tries to find the next JPEG marker in underlying file stream.

Parameters:
lastWasSOSMarker- [in] Denotes, whether the last marker read before was the SOS (start of scan) marker. This is needed to ignore non-marker 0xFF ocurrences in the compressed data.
result- [out] The result marker
Returns:
EC_Normal, if successful, error otherwise
OFCondition I2DJpegSource::openFile ( const OFString filename) [protected]

Opens the JPEG file specified by the given filename.

Parameters:
filename- [in] The file to be opened
Returns:
EC_Normal, if successful, error otherwise
int I2DJpegSource::read1Byte ( Uint8 &  result) [inline, protected]

Read 1 byte from the byte stream.

Parameters:
result- [out] The result
Returns:
0, if successful, EOF if rest of stream does not contain enough bytes
int I2DJpegSource::read2Bytes ( Uint16 &  result) [inline, 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
OFCondition I2DJpegSource::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 JPEG pixel data stream from a JPEG file and returns some image information about this pixel data.

Raw means here that all APP markers (e.g. JFIF information) are removed from the JPEG stream. The pixel data returned is a JPEG stream in JPEG interchange format. 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 JPEG 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 JPEG importer that needs to report which TS must be used for the imported JPEG data (ie. baseline, progressive, ...).
Returns:
EC_Normal, if successful, error otherwise

Implements I2DImgSource.

void I2DJpegSource::setExtSeqSupport ( const OFBool  enabled)

Enable/Disable support for Extended Sequential JPEG Coding.

Parameters:
enabled- [in] OFTrue: support Extended Sequential, OFTrue: Do not support
Returns:
none
void I2DJpegSource::setInsistOnJFIF ( const OFBool  enabled)

If enabled, conversion will only take place if JFIF data could be found and evaluated.

Many digital cameras do not provide a JFIF header, so this is disabled by default.

void I2DJpegSource::setKeepAPPn ( const OFBool  enabled)

If enabled, APPn markers (except JFIF!) are also copied to the output file.

This can cause a huge speedup because instead of parsing the whole JPEG file (for finding any APPn markers) the parsing stops after finding the SOFn marker (which is relevant for extracting width/height and so on. Default: false

Parameters:
enabled- [in] OFtrue: copy APPn, OFFalse: cut off APPn info
Returns:
none
void I2DJpegSource::setProgrSupport ( const OFBool  enabled)

Enable/Disable support for Progressive JPEG Coding.

Parameters:
enabled- [in] OFTrue: support Extended Sequential, OFTrue: Do not support
Returns:
none

Skips one marker while scanning through the JPEG file stream.

Returns:
EC_Normal, if successful, error otherwise

Member Data Documentation

OFBool I2DJpegSource::m_insistOnJFIF [protected]

If true, conversion will only work if JFIF header can be found.

Default: false

OFBool I2DJpegSource::m_keepAPPn [protected]

If true, APPn markers (except JFIF!) are also copied to the output file.

This can cause a huge speedup because instead of parsing the whole JPEG file (for finding any APPn markers) the parsing stops after finding the SOFn marker (which is relevant for extracting width/height and so on. Default: false


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