+ }
+ // wow what happen, must be an error
+ gdcmWarningMacro( "gdcm_read_JPEG2000_file() failed ");
+ return false;
+ }
+ else
+ {
+ if( (unsigned int)ZSize != JPEGInfo->GetFragmentCount() )
+ {
+ gdcmErrorMacro( "Sorry GDCM does not handle this type of fragments" );
+ return false;
+ }
+ // Hopefully every dicom fragment is *exactly* the j2k stream
+ JPEGFragment *jpegfrag = JPEGInfo->GetFirstFragment();
+ char *praw = (char*)Raw;
+ while( jpegfrag )
+ {
+ unsigned long inputlength = jpegfrag->GetLength();
+ char *inputdata = new char[inputlength];
+ fp->seekg( jpegfrag->GetOffset(), std::ios::beg);
+ fp->read(inputdata, jpegfrag->GetLength());
+ // Warning the inputdata buffer is deleted in the function
+ gdcm_read_JPEG2000_file( praw,
+ inputdata, inputlength) ;
+ praw += XSize*YSize*SamplesPerPixel*(BitsAllocated/8);
+ jpegfrag = JPEGInfo->GetNextFragment();
+ }
+ return true;
+ }