This is a I2DImgSource implementation that can parse JPEG files and convert them into DICOM images.
More...
|
| I2DJpegSource () |
| Constructor, initializes member variables. More...
|
|
OFString | inputFormat () const |
| Returns format of input image. More...
|
|
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 further information about this pixel data. More...
|
|
OFCondition | getLossyComprInfo (OFBool &srcEncodingLossy, OFString &srcLossyComprMethod) const |
| After reading of pixel data, this function can be used for getting information about lossy compression parameters. More...
|
|
void | setExtSeqSupport (const OFBool enabled) |
| Enable/Disable support for Extended Sequential JPEG Coding. More...
|
|
void | setProgrSupport (const OFBool enabled) |
| Enable/Disable support for Progressive JPEG Coding. More...
|
|
void | setInsistOnJFIF (const OFBool enabled) |
| If enabled, conversion will only take place if JFIF data could be found and evaluated. More...
|
|
void | setKeepAPPn (const OFBool enabled) |
| If enabled, APPn markers (except JFIF!) are also copied to the output file. More...
|
|
| ~I2DJpegSource () |
| Destructor, frees some memory. More...
|
|
| I2DImgSource () |
| Constructor.
|
|
void | setImageFile (const OFString &filename) |
| Sets the input image file to read. More...
|
|
OFString | getImageFile () |
| Returns the input image file that currently associated with plugin. More...
|
|
virtual | ~I2DImgSource () |
| Virtual Destructor.
|
|
|
OFCondition | openFile (const OFString &filename) |
| Opens the JPEG file specified by the given filename. More...
|
|
void | closeFile () |
| Closes JPEG file. More...
|
|
OFCondition | createJPEGFileMap () |
| Function that scans a JPEG file and creates a "file map" which includes all JPEG markers and their byte positions in the file. More...
|
|
void | debugDumpJPEGFileMap () const |
| Dump the internal JPEG file map to a given stream. More...
|
|
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. More...
|
|
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. More...
|
|
OFCondition | isJPEGEncodingSupported (const E_JPGMARKER &jpegEncoding) const |
| Check, whether a given JPEG image marker (SOFn) is supported by this plugin. More...
|
|
OFCondition | extractRawJPEGStream (char *&pixelData, Uint32 &pixLength) |
| Extract raw JPEG stream (i.e. More...
|
|
OFCondition | copyJPEGStream (char *&pixelData, Uint32 &pixLength) |
| Copies JPEG stream (with APPn markers, excluding JFIF) from JPEG file. More...
|
|
OFCondition | skipVariable () |
| Skips one marker while scanning through the JPEG file stream. More...
|
|
OFCondition | firstMarker (E_JPGMARKER &result) |
| Tries to read the SOI marker. More...
|
|
OFCondition | nextMarker (const OFBool &lastWasSOSMarker, E_JPGMARKER &result) |
| Tries to find the next JPEG marker in underlying file stream. More...
|
|
int | read2Bytes (Uint16 &result) |
| Read 2 bytes from the byte stream. More...
|
|
int | read1Byte (Uint8 &result) |
| Read 1 byte from the byte stream. More...
|
|
void | clearMap () |
| Deletes internal JPEG file map and frees memory. More...
|
|
|
static E_TransferSyntax | associatedTS (const E_JPGMARKER &jpegEncoding) |
| Returns if possible the DICOM transfer syntax matching the coding of the JPEG data. More...
|
|
static OFBool | isRSTMarker (const E_JPGMARKER &jpegEncoding) |
| Returns true if marker is one of the RST0 to RST7 markers. More...
|
|
static OFBool | isSOFMarker (const E_JPGMARKER &jpegEncoding) |
| Returns true if marker is one of the SOF0 to SOF15 markers. More...
|
|
This is a I2DImgSource implementation that can parse JPEG files and convert them into DICOM images.
I2DJpegSource::I2DJpegSource |
( |
| ) |
|
Constructor, initializes member variables.
- Returns
- none
I2DJpegSource::~I2DJpegSource |
( |
| ) |
|
Destructor, frees some memory.
- Returns
- none
static E_TransferSyntax I2DJpegSource::associatedTS |
( |
const E_JPGMARKER & |
jpegEncoding | ) |
|
|
staticprotected |
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 markers 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
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.
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] Number 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 | ) |
|
|
staticprotected |
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 | ) |
|
|
staticprotected |
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 occurrences in the compressed data. |
result | - [out] The result marker |
- Returns
- EC_Normal, if successful, error otherwise
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 | ) |
|
|
inlineprotected |
Read 1 byte from the byte stream.
- Parameters
-
- Returns
- 0, if successful, EOF if rest of stream does not contain enough bytes
int I2DJpegSource::read2Bytes |
( |
Uint16 & |
result | ) |
|
|
inlineprotected |
Read 2 bytes from the byte stream.
- Parameters
-
- 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 further 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, OFFalse: 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, OFFalse: do not support |
- Returns
- none
Skips one marker while scanning through the JPEG file stream.
- Returns
- EC_Normal, if successful, error otherwise
OFBool I2DJpegSource::m_insistOnJFIF |
|
protected |
If true, conversion will only work if JFIF header can be found.
Default: false
JPEG file map.
This map includes all JPEG markers and their byte positions in the JPEG file.
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:
- dcmdata/include/dcmtk/dcmdata/libi2d/i2djpgs.h