]> Creatis software - gdcm.git/blobdiff - src/gdcmFileHelper.cxx
remove useless comments
[gdcm.git] / src / gdcmFileHelper.cxx
index 700904b6f7204164494e3e04207d10663c987ea7..50183d7004aa0ab93119013bf7a83d99fd9e1a7d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFileHelper.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/05 01:37:08 $
-  Version:   $Revision: 1.13 $
+  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
@@ -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;