X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmFileHelper.cxx;h=50183d7004aa0ab93119013bf7a83d99fd9e1a7d;hb=b330c6f291515e40582b3aa1258d1a27b628aac3;hp=bde7e0f936c1511c7ffaf8411c4a6e0c8239e8c7;hpb=0f8bcdd7eb7538bda5c38c4587c0ae54cb0c3693;p=gdcm.git diff --git a/src/gdcmFileHelper.cxx b/src/gdcmFileHelper.cxx index bde7e0f9..50183d70 100644 --- a/src/gdcmFileHelper.cxx +++ b/src/gdcmFileHelper.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFileHelper.cxx,v $ Language: C++ - Date: $Date: 2005/02/04 14:49:01 $ - Version: $Revision: 1.12 $ + Date: $Date: 2005/02/11 11:22:59 $ + Version: $Revision: 1.16 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -320,7 +320,7 @@ size_t FileHelper::GetImageDataIntoVector (void *destination, size_t maxSize) { if ( PixelReadConverter->GetRGBSize() > maxSize ) { - gdcmVerboseMacro( "Pixel data bigger than caller's expected MaxSize"); + gdcmWarningMacro( "Pixel data bigger than caller's expected MaxSize"); return 0; } memcpy( destination, @@ -332,7 +332,7 @@ size_t FileHelper::GetImageDataIntoVector (void *destination, size_t maxSize) // Either no LUT conversion necessary or LUT conversion failed if ( PixelReadConverter->GetRawSize() > maxSize ) { - gdcmVerboseMacro( "Pixel data bigger than caller's expected MaxSize"); + gdcmWarningMacro( "Pixel data bigger than caller's expected MaxSize"); return 0; } memcpy( destination, @@ -450,7 +450,7 @@ bool FileHelper::WriteRawData(std::string const &fileName) std::ofstream fp1(fileName.c_str(), std::ios::out | std::ios::binary ); if (!fp1) { - gdcmVerboseMacro( "Fail to open (write) file:" << fileName.c_str()); + gdcmWarningMacro( "Fail to open (write) file:" << fileName.c_str()); return false; } @@ -635,7 +635,7 @@ bool FileHelper::CheckWriteIntegrity() case WMODE_RAW : if( decSize!=PixelWriteConverter->GetUserDataSize() ) { - gdcmVerboseMacro( "Data size (Raw) is incorrect. Should be " + gdcmWarningMacro( "Data size (Raw) is incorrect. Should be " << decSize << " / Found :" << PixelWriteConverter->GetUserDataSize() ); return false; @@ -644,7 +644,7 @@ bool FileHelper::CheckWriteIntegrity() case WMODE_RGB : if( rgbSize!=PixelWriteConverter->GetUserDataSize() ) { - gdcmVerboseMacro( "Data size (RGB) is incorrect. Should be " + gdcmWarningMacro( "Data size (RGB) is incorrect. Should be " << decSize << " / Found " << PixelWriteConverter->GetUserDataSize() ); return false; @@ -675,14 +675,19 @@ void FileHelper::SetWriteToRaw() } else { - photInt->SetValue("MONOCHROME1 "); + photInt->SetValue("MONOCHROME2 "); } PixelWriteConverter->SetReadData(PixelReadConverter->GetRaw(), PixelReadConverter->GetRawSize()); + std::string vr = "OB"; + if( FileInternal->GetBitsAllocated()>8 ) + vr = "OW"; + if( FileInternal->GetBitsAllocated()==24 ) // For RGB ACR files + vr = "OB"; BinEntry *pixel = - CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel()); + CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr); pixel->SetValue(GDCM_BINLOADED); pixel->SetBinArea(PixelWriteConverter->GetData(),false); pixel->SetLength(PixelWriteConverter->GetDataSize()); @@ -721,8 +726,13 @@ void FileHelper::SetWriteToRGB() PixelReadConverter->GetRawSize()); } + std::string vr = "OB"; + if( FileInternal->GetBitsAllocated()>8 ) + vr = "OW"; + if( FileInternal->GetBitsAllocated()==24 ) // For RGB ACR files + vr = "OB"; BinEntry *pixel = - CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel()); + CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr); pixel->SetValue(GDCM_BINLOADED); pixel->SetBinArea(PixelWriteConverter->GetData(),false); pixel->SetLength(PixelWriteConverter->GetDataSize()); @@ -906,7 +916,7 @@ ValEntry *FileHelper::CopyValEntry(uint16_t group,uint16_t elem) DocEntry *oldE = FileInternal->GetDocEntry(group, elem); ValEntry *newE; - if(oldE) + if( oldE ) { newE = new ValEntry(oldE->GetDictEntry()); newE->Copy(oldE); @@ -924,22 +934,28 @@ ValEntry *FileHelper::CopyValEntry(uint16_t group,uint16_t elem) * when it exists. Create it with the given value when unexistant. * @param group Group number of the Entry * @param elem Element number of the Entry + * @param vr Value Representation of the Entry * \return pointer to the modified/created Bin Entry (NULL when creation * failed). */ -BinEntry *FileHelper::CopyBinEntry(uint16_t group,uint16_t elem) +BinEntry *FileHelper::CopyBinEntry(uint16_t group,uint16_t elem, + const std::string &vr) { DocEntry *oldE = FileInternal->GetDocEntry(group, elem); BinEntry *newE; - if(oldE) + if( oldE ) + if( oldE->GetVR()!=vr ) + oldE = NULL; + + if( oldE ) { newE = new BinEntry(oldE->GetDictEntry()); newE->Copy(oldE); } else { - newE = GetFile()->NewBinEntry(group,elem); + newE = GetFile()->NewBinEntry(group,elem,vr); } return newE; @@ -982,7 +998,7 @@ uint8_t *FileHelper::GetRaw() raw = PixelReadConverter->GetRaw(); if ( ! raw ) { - gdcmVerboseMacro( "Read/decompress of pixel data apparently went wrong."); + gdcmWarningMacro( "Read/decompress of pixel data apparently went wrong."); return 0; } }