X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmFile.cxx;h=50eeeba71a8320490354f92d6e6f44e8755fd9dd;hb=06e5584ba82b9878b3e544a53c9575cf363fdb8c;hp=2721d9ad1e8d57bc771472ffed29920ed7006875;hpb=b158878c883def8179e3eccc27fcea5bb6035a4c;p=gdcm.git diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 2721d9ad..50eeeba7 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -1,5 +1,17 @@ // gdcmFile.cxx +//This is needed when compiling in debug mode +#ifdef _MSC_VER +// 'type' : forcing value to bool 'true' or 'false' (performance warning) +//#pragma warning ( disable : 4800 ) +// 'identifier' : class 'type' needs to have dll-interface to be used by +// clients of class 'type2' +#pragma warning ( disable : 4251 ) +// 'identifier' : identifier was truncated to 'number' characters in the +// debug information +#pragma warning ( disable : 4786 ) +#endif //_MSC_VER + #include "gdcmFile.h" #include "gdcmUtil.h" #include "iddcmjpeg.h" // for the 'LibIDO' Jpeg LossLess @@ -52,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() ); @@ -115,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() ); @@ -240,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() ); @@ -396,7 +408,7 @@ bool gdcmFile::ReadPixelData(void* destination) { // FIXME : will work only when each fragment corresponds to a Frame :-( - (char *) destination += taille * nBytes; // location in user's memory + destination = (char *)destination + taille * nBytes; // location in user's memory // for next fragment (if any) // TODO : find a suitable file (multifragment/single Frame Jpeg file) to check @@ -460,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() ); @@ -468,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() ); @@ -476,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() ); @@ -484,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() ); @@ -852,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);