- }
- }
- else if ( BitsStored <= 12)
- {
- if ( ! gdcm_read_JPEG_memory12( buffer, totalLength, Raw,
- &howManyRead, &howManyWritten ) )
- {
- dbg.Error(
- "PixelConvert::ReadAndDecompressJPEGFile: failed to read jpeg12 "
- );
- delete [] buffer;
- return false;
- }
- }
- else if ( BitsStored <= 16)
- {
-
- if ( ! gdcm_read_JPEG_memory16( buffer, totalLength, Raw,
- &howManyRead, &howManyWritten ) )
- {
- dbg.Error(
- "PixelConvert::ReadAndDecompressJPEGFile: failed to read jpeg16 "
- );
- delete [] buffer;
- return false;
- }
- }
- else
- {
- // other JPEG lossy not supported
- dbg.Error("PixelConvert::ReadAndDecompressJPEGFile: unknown "
- "jpeg lossy compression ");
- delete [] buffer;
- return false;
- }
-
- // free local buffer
- delete [] buffer;
-
- return true;
-}
-
-/**
- * \brief Reads from disk the Pixel Data of JPEG Dicom encapsulated
- * file and decompress it. This function handles the generic
- * and complex case where the DICOM contains several frames,
- * and some of the frames are possibly split into several JPEG
- * fragments.
- * @param fp File Pointer
- * @return Boolean
- */
-bool PixelReadConvert::
-ReadAndDecompressJPEGFragmentedFramesFromFile( std::ifstream* fp )
-{
- // Loop on the fragment[s] to get total length
- size_t totalLength = 0;
- JPEGFragmentsInfo::JPEGFragmentsList::iterator it;
- for( it = JPEGInfo->Fragments.begin();
- it != JPEGInfo->Fragments.end();
- ++it )
- {
- totalLength += (*it)->Length;
- }
-
- // Concatenate the jpeg fragments into a local buffer
- JOCTET *buffer = new JOCTET [totalLength];
- JOCTET *p = buffer;
-
- // Loop on the fragment[s]
- for( it = JPEGInfo->Fragments.begin();
- it != JPEGInfo->Fragments.end();
- ++it )
- {
- fp->seekg( (*it)->Offset, std::ios::beg);
- size_t len = (*it)->Length;
- fp->read((char *)p,len);
- p+=len;