+2004-11-24 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+ * Amelioration of code, remove some code copy. For the loading of
+ BinEntry (in gdcmDocument), add the test to verify if the file is already
+ opened or not.
+
2004-11-24 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
* src/gdcmDocEntryArchive.[h|cxx] : bug fix and add a method to temporary
remove a DocEntry in the header (push an empty DocEntry)
Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2004/11/19 12:44:00 $
- Version: $Revision: 1.135 $
+ Date: $Date: 2004/11/24 11:17:47 $
+ Version: $Revision: 1.136 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
if ( !docElement )
return;
- size_t o =(size_t)docElement->GetOffset();
+ BinEntry *binElement = dynamic_cast<BinEntry *>(docElement);
+ if( !binElement )
+ return;
+
+ LoadEntryBinArea(binElement);
+/* size_t o =(size_t)docElement->GetOffset();
Fp->seekg( o, std::ios_base::beg);
size_t l = docElement->GetLength();
uint8_t* a = new uint8_t[l];
{
delete[] a;
dbg.Verbose(0, "Document::LoadEntryBinArea setting failed.");
- }
+ }*/
}
+
/**
* \brief Loads (from disk) the element content
* when a string is not suitable
*/
void Document::LoadEntryBinArea(BinEntry* element)
{
+ bool openFile = !Fp;
+ if(openFile)
+ OpenFile();
+
size_t o =(size_t)element->GetOffset();
Fp->seekg(o, std::ios_base::beg);
+
size_t l = element->GetLength();
uint8_t* a = new uint8_t[l];
if( !a )
}
element->SetBinArea(a);
+
+ if(openFile)
+ CloseFile();
}
/**
Program: gdcm
Module: $RCSfile: gdcmDocument.h,v $
Language: C++
- Date: $Date: 2004/11/17 19:49:13 $
- Version: $Revision: 1.61 $
+ Date: $Date: 2004/11/24 11:17:47 $
+ Version: $Revision: 1.62 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/// 'Swap code' accessor (see \ref SwapCode )
int GetSwapCode() { return SwapCode; }
- /// File pointer
- std::ifstream * GetFP() { return Fp; }
-
bool operator<(Document &document);
};
Program: gdcm
Module: $RCSfile: gdcmFile.cxx,v $
Language: C++
- Date: $Date: 2004/11/24 10:23:47 $
- Version: $Revision: 1.160 $
+ Date: $Date: 2004/11/24 11:17:47 $
+ Version: $Revision: 1.161 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
return 0;
}
+ if ( HeaderInternal->HasLUT() && PixelConverter->BuildRGBImage() )
+ {
+ return PixelConverter->GetRGB();
+ }
+ else
+ {
+ // When no LUT or LUT conversion fails, return the decompressed
+ return PixelConverter->GetDecompressed();
+ }
+
+/* if ( ! GetDecompressed() )
+ {
+ // If the decompression failed nothing can be done.
+ return 0;
+ }
+
uint8_t* pixelData;
if ( HeaderInternal->HasLUT() && PixelConverter->BuildRGBImage() )
{
pixelData = PixelConverter->GetDecompressed();
}
-/*// PIXELCONVERT CLEANME
+// PIXELCONVERT CLEANME
// Restore the header in a disk-consistent state
// (if user asks twice to get the pixels from disk)
if ( PixelRead != -1 ) // File was "read" before
// We say the value *is* loaded.
SetPixelData(pixelData);
-// END PIXELCONVERT CLEANME*/
+// END PIXELCONVERT CLEANME
- return pixelData;
+ return pixelData;*/
}
/**
*/
uint8_t* File::GetImageDataRaw ()
{
- uint8_t* decompressed = GetDecompressed();
+ return GetDecompressed();
+/* uint8_t* decompressed = GetDecompressed();
if ( ! decompressed )
{
return 0;
}
-/*// PIXELCONVERT CLEANME
+// PIXELCONVERT CLEANME
// Restore the header in a disk-consistent state
// (if user asks twice to get the pixels from disk)
if ( PixelRead != -1 ) // File was "read" before
SetPixelData(decompressed);
PixelRead = 1; // PixelRaw
-// END PIXELCONVERT CLEANME*/
+// END PIXELCONVERT CLEANME
- return decompressed;
+ return decompressed;*/
}
uint8_t* File::GetDecompressed()