]> Creatis software - gdcm.git/blobdiff - src/gdcmFile.cxx
* oops forgot to commit Changelog :)
[gdcm.git] / src / gdcmFile.cxx
index ddde9fe44edd128eaf2c2157508876e15d136801..50eeeba71a8320490354f92d6e6f44e8755fd9dd 100644 (file)
@@ -64,7 +64,7 @@ void gdcmFile::SetPixelDataSizeFromHeader(void) {
    string str_nb;
 
    str_nb=gdcmHeader::GetPubElValByNumber(0x0028,0x0100);
-   if (str_nb == "gdcm::Unfound" ) {
+   if (str_nb == GDCM_UNFOUND ) {
       nb = 16;
    } else {
       nb = atoi(str_nb.c_str() );
@@ -127,7 +127,7 @@ bool gdcmFile::ParsePixelData(void) {
 
    int nb;
    string str_nb=gdcmHeader::GetPubElValByNumber(0x0028,0x0100);
-   if (str_nb == "gdcm::Unfound" ) {
+   if (str_nb == GDCM_UNFOUND ) {
       nb = 16;
    } else {
       nb = atoi(str_nb.c_str() );
@@ -252,7 +252,7 @@ bool gdcmFile::ReadPixelData(void* destination) {
        
       int nb;
       string str_nb=gdcmHeader::GetPubElValByNumber(0x0028,0x0100);
-      if (str_nb == "gdcm::Unfound" ) {
+      if (str_nb == GDCM_UNFOUND ) {
          nb = 16;
       } else {
          nb = atoi(str_nb.c_str() );
@@ -472,7 +472,7 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) {
                        
        // Nombre de Bits Alloues pour le stockage d'un Pixel
    str_nb = GetPubElValByNumber(0x0028,0x0100);
-   if (str_nb == "gdcm::Unfound" ) {
+   if (str_nb == GDCM_UNFOUND ) {
       nb = 16;
    } else {
       nb = atoi(str_nb.c_str() );
@@ -480,7 +480,7 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) {
        
        // Nombre de Bits Utilises
    str_nbu=GetPubElValByNumber(0x0028,0x0101);
-   if (str_nbu == "gdcm::Unfound" ) {
+   if (str_nbu == GDCM_UNFOUND ) {
       nbu = nb;
    } else {
       nbu = atoi(str_nbu.c_str() );
@@ -488,7 +488,7 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) {
        
        // Position du Bit de Poids Fort
    str_highBit=GetPubElValByNumber(0x0028,0x0102);
-   if (str_highBit == "gdcm::Unfound" ) {
+   if (str_highBit == GDCM_UNFOUND ) {
       highBit = nb - 1;
    } else {
       highBit = atoi(str_highBit.c_str() );
@@ -496,7 +496,7 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) {
                
        // Signe des Pixels 
    str_signe=GetPubElValByNumber(0x0028,0x0103);
-   if (str_signe == "gdcm::Unfound" ) {
+   if (str_signe == GDCM_UNFOUND ) {
       signe = 1;
    } else {
       signe = atoi(str_signe.c_str() );
@@ -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);