]> Creatis software - gdcm.git/commitdiff
Special patch to allow gdcm to read ACR-LibIDO formatted images
authorjpr <jpr>
Thu, 11 Sep 2003 11:12:59 +0000 (11:12 +0000)
committerjpr <jpr>
Thu, 11 Sep 2003 11:12:59 +0000 (11:12 +0000)
(if recognition code = ACR_LIBIDO, we switch ROWS and COLUMN)

All the gdcmFile::WriteXXX now produce a LibIDO/gdcm readable ACR_LibIDO image
when the source was an ACR_LibIDO image.

src/gdcmFile.cxx
src/gdcmHeader.cxx

index ddde9fe44edd128eaf2c2157508876e15d136801..58da7385690e835c033bb3325b8aaf6c9d19fb62 100644 (file)
@@ -864,7 +864,36 @@ int gdcmFile::WriteBase (string FileName, FileType type) {
       fwrite("DICM",4,1,fp1);
    }
 
+   // --------------------------------------------------------------
+   // Special Patch to allow gdcm to re-write ACR-LibIDO formated images
+   //
+   // if recognition code tells us we dealt with a LibIDO image
+   // we reproduce on disk the switch between lineNumber and columnNumber
+   // just before writting ...
+
+   std::string rows, columns; 
+   if ( filetype == ACR_LIBIDO){
+         rows    = GetPubElValByNumber(0x0028, 0x0010);
+         columns = GetPubElValByNumber(0x0028, 0x0011);
+         SetPubElValByNumber(columns,  0x0028, 0x0010);
+         SetPubElValByNumber(rows   ,  0x0028, 0x0011);
+   }   
+   // ----------------- End of Special Patch ----------------
+
    gdcmHeader::Write(fp1, type);
+
+   // --------------------------------------------------------------
+   // Special Patch to allow gdcm to re-write ACR-LibIDO formated images
+   // 
+   // ...and we restore the Header to be Dicom Compliant again 
+   // just after writting
+
+   if (filetype == ACR_LIBIDO){
+         SetPubElValByNumber(rows   , 0x0028, 0x0010);
+         SetPubElValByNumber(columns, 0x0028, 0x0011);
+   }   
+   // ----------------- End of Special Patch ----------------
+
    fwrite(PixelData, lgrTotale, 1, fp1);
    fclose (fp1);
    return(1);
index 1c4876da3b92dc503d3ccff6325e7fd762e5979b..30806b6775ec81a831f470558abf8151a2470fc3 100644 (file)
@@ -1,4 +1,4 @@
-// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.cxx,v 1.82 2003/09/10 16:31:24 malaterre Exp $
+// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.cxx,v 1.83 2003/09/11 11:12:59 jpr Exp $
 
 //This is needed when compiling in debug mode
 #ifdef _MSC_VER
@@ -1697,8 +1697,9 @@ void gdcmHeader::LoadElements(void) {
    for (TagElValueHT::iterator tag = ht.begin(); tag != ht.end(); ++tag) {
       LoadElementValue(tag->second);
    }
-   // Load 'non string' values
-   rewind(fp);    
+   rewind(fp);
+
+   // Load 'non string' values   
    string PhotometricInterpretation = GetPubElValByNumber(0x0028,0x0004);   
    if( PhotometricInterpretation == "PALETTE COLOR " ){ 
       LoadElementVoidArea(0x0028,0x1200);  // gray LUT   
@@ -1710,6 +1711,24 @@ void gdcmHeader::LoadElements(void) {
       LoadElementVoidArea(0x0028,0x1222);  // Segmented Green Palette Color LUT Data
       LoadElementVoidArea(0x0028,0x1223);  // Segmented Blue  Palette Color LUT Data
    }
+
+   // --------------------------------------------------------------
+   // Special Patch to allow gdcm to read ACR-LibIDO formated images
+   //
+   // if recognition code tells us we deal with a LibIDO image
+   // we switch lineNumber and columnNumber
+   //
+   string RecCode;     
+   RecCode = GetPubElValByNumber(0x0008, 0x0010);
+   if (RecCode == "ACRNEMA_LIBIDO_1.1" ||
+       RecCode == "CANRME_AILIBOD1_1." ) {
+         filetype = ACR_LIBIDO; 
+         std::string rows    = GetPubElValByNumber(0x0028, 0x0010);
+         std::string columns = GetPubElValByNumber(0x0028, 0x0011);
+         SetPubElValByNumber(columns, 0x0028, 0x0010);
+         SetPubElValByNumber(rows   , 0x0028, 0x0011);
+   }
+   // ----------------- End of Special Patch ----------------
 }
 
 /**