-size_t gdcmFile::GetImageDataIntoVectorRaw (void *destination, size_t MaxSize) {
-
- int nb, nbu, highBit, signe;
- std::string str_nbFrames, str_nb, str_nbu, str_highBit, str_signe;
- PixelRead=1 ; // PixelRaw
-
- if ( lgrTotale > MaxSize ) {
+size_t gdcmFile::GetImageDataIntoVectorRaw (void *destination, size_t maxSize)
+{
+ int nb, nbu, highBit, sign;
+
+ // we save the initial values of the following
+ // in order to be able to restore the header in a disk-consistent state
+ // (if user asks twice to get the pixels from disk)
+
+ if ( PixelRead == -1 ) // File was never "read" before
+ {
+ InitialSpp = Header->GetEntryByNumber(0x0028,0x0002);
+ InitialPhotInt = Header->GetEntryByNumber(0x0028,0x0004);
+ InitialPlanConfig = Header->GetEntryByNumber(0x0028,0x0006);
+ InitialBitsAllocated = Header->GetEntryByNumber(0x0028,0x0100);
+ }
+ else // File was already "read", the following *may* have been modified
+ // we restore them to be in a disk-consistent state
+ {
+ // FIXME : What happened with the LUTs ?
+ Header->SetEntryByNumber(InitialSpp,0x0028,0x0002);
+ Header->SetEntryByNumber(InitialPhotInt,0x0028,0x0004);
+ Header->SetEntryByNumber(InitialPlanConfig,0x0028,0x0006);
+ Header->SetEntryByNumber(InitialBitsAllocated,0x0028,0x0100);
+ }
+
+ PixelRead = 1 ; // PixelRaw
+
+ if ( ImageDataSize > maxSize )
+ {