-
-/**
- * \brief Reads from disk the Pixel Data of JPEG Dicom encapsulated
- * file and decompress it. This funciton assumes that each
- * jpeg fragment contains a whole frame (jpeg file).
- * @param fp File Pointer
- * @return Boolean
- */
-bool PixelReadConvert::ReadAndDecompressJPEGFramesFromFile( std::ifstream* fp )
-{
- uint8_t* localRaw = Raw;
- // Loop on the fragment[s]
- for( JPEGFragmentsInfo::JPEGFragmentsList::iterator
- it = JPEGInfo->Fragments.begin();
- it != JPEGInfo->Fragments.end();
- ++it )
- {
- fp->seekg( (*it)->Offset, std::ios::beg);
-
- if ( BitsStored == 8)
- {
- // JPEG Lossy : call to IJG 6b
- if ( ! gdcm_read_JPEG_file8( fp, localRaw ) )
- {
- return false;
- }
- }
- else if ( BitsStored <= 12)
- {
- // Reading Fragment pixels
- if ( ! gdcm_read_JPEG_file12 ( fp, localRaw ) )
- {
- return false;
- }
- }
- else if ( BitsStored <= 16)
- {
- // Reading Fragment pixels
- if ( ! gdcm_read_JPEG_file16 ( fp, localRaw ) )
- {
- return false;
- }
- //assert( IsJPEGLossless );
- }
- else
- {
- // other JPEG lossy not supported
- dbg.Error("PixelReadConvert::ReadAndDecompressJPEGFile: unknown "
- "jpeg lossy compression ");
- return false;
- }
-
- // Advance to next free location in Raw
- // for next fragment decompression (if any)
- int length = XSize * YSize * SamplesPerPixel;
- int numberBytes = BitsAllocated / 8;
-
- localRaw += length * numberBytes;
- }
- return true;
-}
-