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
{
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,
// 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,
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;
}
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;
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;
}
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());
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());
DocEntry *oldE = FileInternal->GetDocEntry(group, elem);
ValEntry *newE;
- if(oldE)
+ if( oldE )
{
newE = new ValEntry(oldE->GetDictEntry());
newE->Copy(oldE);
* 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;
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;
}
}