X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmFile.cxx;h=328845eaebdb129d2aaa08c969ff110f6645fd20;hb=b1cbd2d3c12ccac8b257901236fe8eb27a20b117;hp=e94c9c4f953ece9c1228411316354e9cb0ce1027;hpb=49484255e3674c038cbf2259a8c3325c0039cd41;p=gdcm.git diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index e94c9c4f..328845ea 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -124,7 +124,7 @@ void gdcmFile::SetPixelDataSizeFromHeader(void) { int nb; std::string str_nb; - str_nb=Header->GetPubEntryByNumber(0x0028,0x0100); + str_nb=Header->GetEntryByNumber(0x0028,0x0100); if (str_nb == GDCM_UNFOUND ) { nb = 16; } else { @@ -134,7 +134,7 @@ void gdcmFile::SetPixelDataSizeFromHeader(void) { lgrTotale = lgrTotaleRaw = Header->GetXSize() * Header->GetYSize() * Header->GetZSize() * (nb/8)* Header->GetSamplesPerPixel(); std::string str_PhotometricInterpretation = - Header->GetPubEntryByNumber(0x0028,0x0004); + Header->GetEntryByNumber(0x0028,0x0004); /*if ( str_PhotometricInterpretation == "PALETTE COLOR " )*/ // pb when undealt Segmented Palette Color @@ -172,8 +172,8 @@ size_t gdcmFile::GetImageDataSizeRaw(void) { * \brief Allocates necessary memory, copies the pixel data * (image[s]/volume[s]) to newly allocated zone. * Transforms YBR pixels into RGB pixels if any - Transforms 3 planes R, G, B into a single RGB Plane - Transforms single Grey plane + 3 Palettes into a RGB Plane + * Transforms 3 planes R, G, B into a single RGB Plane + * Transforms single Grey plane + 3 Palettes into a RGB Plane * @return Pointer to newly allocated pixel data. * \ NULL if alloc fails */ @@ -233,11 +233,11 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) { // CreateOrReplaceIfExist ? std::string spp = "3"; // Samples Per Pixel - Header->SetPubEntryByNumber(spp,0x0028,0x0002); + Header->SetEntryByNumber(spp,0x0028,0x0002); std::string rgb= "RGB "; // Photometric Interpretation - Header->SetPubEntryByNumber(rgb,0x0028,0x0004); + Header->SetEntryByNumber(rgb,0x0028,0x0004); std::string planConfig = "0"; // Planar Configuration - Header->SetPubEntryByNumber(planConfig,0x0028,0x0006); + Header->SetEntryByNumber(planConfig,0x0028,0x0006); } else { // need to make RGB Pixels (?) @@ -251,7 +251,7 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) { // Segmented xxx Palette Color are *more* than 65535 long ?!? std::string rgb= "MONOCHROME1 "; // Photometric Interpretation - Header->SetPubEntryByNumber(rgb,0x0028,0x0004); + Header->SetEntryByNumber(rgb,0x0028,0x0004); } // TODO : Drop Palette Color out of the Header? return lgrTotale; @@ -262,8 +262,8 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) { * \brief Allocates necessary memory, copies the pixel data * (image[s]/volume[s]) to newly allocated zone. * Transforms YBR pixels into RGB pixels if any - Transforms 3 planes R, G, B into a single RGB Plane - DOES NOT transform Grey plane + 3 Palettes into a RGB Plane + * Transforms 3 planes R, G, B into a single RGB Plane + * DOES NOT transform Grey plane + 3 Palettes into a RGB Plane * @return Pointer to newly allocated pixel data. * \ NULL if alloc fails */ @@ -316,21 +316,21 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t MaxSize) { (void)ReadPixelData(destination); // Number of Bits Allocated for storing a Pixel - str_nb = Header->GetPubEntryByNumber(0x0028,0x0100); + str_nb = Header->GetEntryByNumber(0x0028,0x0100); if (str_nb == GDCM_UNFOUND ) { nb = 16; } else { nb = atoi(str_nb.c_str() ); } // Number of Bits actually used - str_nbu=Header->GetPubEntryByNumber(0x0028,0x0101); + str_nbu=Header->GetEntryByNumber(0x0028,0x0101); if (str_nbu == GDCM_UNFOUND ) { nbu = nb; } else { nbu = atoi(str_nbu.c_str() ); } // High Bit Position - str_highBit=Header->GetPubEntryByNumber(0x0028,0x0102); + str_highBit=Header->GetEntryByNumber(0x0028,0x0102); if (str_highBit == GDCM_UNFOUND ) { highBit = nb - 1; } else { @@ -339,7 +339,7 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t MaxSize) { // Pixel sign // 0 = Unsigned // 1 = Signed - str_signe=Header->GetPubEntryByNumber(0x0028,0x0103); + str_signe=Header->GetEntryByNumber(0x0028,0x0103); if (str_signe == GDCM_UNFOUND ) { signe = 0; // default is unsigned } else { @@ -397,7 +397,7 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t MaxSize) { // ------------------- std::string str_PhotometricInterpretation = - Header->GetPubEntryByNumber(0x0028,0x0004); + Header->GetEntryByNumber(0x0028,0x0004); if ( (str_PhotometricInterpretation == "MONOCHROME1 ") || (str_PhotometricInterpretation == "MONOCHROME2 ") ) { @@ -509,12 +509,12 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t MaxSize) { // CreateOrReplaceIfExist ? std::string spp = "3"; // Samples Per Pixel - Header->SetPubEntryByNumber(spp,0x0028,0x0002); + Header->SetEntryByNumber(spp,0x0028,0x0002); std::string rgb="RGB "; // Photometric Interpretation - Header->SetPubEntryByNumber(rgb,0x0028,0x0004); + Header->SetEntryByNumber(rgb,0x0028,0x0004); std::string planConfig = "0"; // Planar Configuration - Header->SetPubEntryByNumber(planConfig,0x0028,0x0006); + Header->SetEntryByNumber(planConfig,0x0028,0x0006); // TODO : Drop Palette Color out of the Header? return lgrTotale; @@ -594,7 +594,7 @@ bool gdcmFile::WriteDcmImplVR (const char* fileName) { * \ingroup gdcmFile * \brief * @param fileName name of the file to be created - * (any already existing file is over written) + * (any already existing file is overwritten) * @return false if write fails */ @@ -609,12 +609,12 @@ bool gdcmFile::WriteDcmExplVR (std::string fileName) { * qui ne prennent en entrée QUE des images ACR ... * \warning if a DICOM_V3 header is supplied, * groups < 0x0008 and shadow groups are ignored) - * \warning NO TEST is performed on processor "Endiannerie". + * \warning NO TEST is performed on processor "Endiannity". * Ca fonctionnera correctement (?) sur processeur Intel * (Equivalent a IdDcmWrite) * * @param fileName name of the file to be created - * (any already existing file is over written) + * (any already existing file is overwritten) * @return false if write fails */ @@ -628,16 +628,16 @@ bool gdcmFile::WriteAcr (std::string fileName) { * \ingroup gdcmFile * * @param fileName name of the file to be created - * (any already existing file is over written) + * (any already existing file is overwritten) * @param type file type (ExplicitVR, ImplicitVR, ...) * @return false if write fails */ -bool gdcmFile::WriteBase (std::string FileName, FileType type) { +bool gdcmFile::WriteBase (std::string fileName, FileType type) { FILE * fp1; - fp1 = fopen(FileName.c_str(),"wb"); + fp1 = fopen(fileName.c_str(),"wb"); if (fp1 == NULL) { - printf("Echec ouverture (ecriture) Fichier [%s] \n",FileName.c_str()); + printf("Echec ouverture (ecriture) Fichier [%s] \n",fileName.c_str()); return (false); } @@ -658,10 +658,10 @@ bool gdcmFile::WriteBase (std::string FileName, FileType type) { std::string rows, columns; if ( Header->GetFileType() == ACR_LIBIDO){ - rows = Header->GetPubEntryByNumber(0x0028, 0x0010); - columns = Header->GetPubEntryByNumber(0x0028, 0x0011); - Header->SetPubEntryByNumber(columns, 0x0028, 0x0010); - Header->SetPubEntryByNumber(rows , 0x0028, 0x0011); + rows = Header->GetEntryByNumber(0x0028, 0x0010); + columns = Header->GetEntryByNumber(0x0028, 0x0011); + Header->SetEntryByNumber(columns, 0x0028, 0x0010); + Header->SetEntryByNumber(rows , 0x0028, 0x0011); } // ----------------- End of Special Patch ---------------- @@ -674,8 +674,8 @@ bool gdcmFile::WriteBase (std::string FileName, FileType type) { // just after writting if (Header->GetFileType() == ACR_LIBIDO){ - Header->SetPubEntryByNumber(rows , 0x0028, 0x0010); - Header->SetPubEntryByNumber(columns, 0x0028, 0x0011); + Header->SetEntryByNumber(rows , 0x0028, 0x0010); + Header->SetEntryByNumber(columns, 0x0028, 0x0011); } // ----------------- End of Special Patch ---------------- @@ -799,12 +799,14 @@ bool gdcmFile::ReadPixelData(void* destination) { fread(&b2,1,1,fp); //Two steps is necessary to please VC++ *pdestination++ = ((b0 >> 4) << 8) + ((b0 & 0x0f) << 4) + (b1 & 0x0f); - /* A */ /* B */ /* D */ + /* A */ /* B */ /* D */ *pdestination++ = ((b2 & 0x0f) << 8) + ((b1 >> 4) << 4) + (b2 >> 4); - /* F */ /* C */ /* E */ + /* F */ /* C */ /* E */ // Troubles expected on Big-Endian processors ? } + + Header->CloseFile(); return(true); } @@ -816,7 +818,6 @@ bool gdcmFile::ReadPixelData(void* destination) { Header->IsDeflatedExplicitVRLittleEndianTransferSyntax() ) { size_t ItemRead = fread(destination, Header->GetPixelAreaLength(), 1, fp); - if ( ItemRead != 1 ) { Header->CloseFile(); return false; @@ -828,13 +829,14 @@ bool gdcmFile::ReadPixelData(void* destination) { // ---------------------- Run Length Encoding if (Header->IsRLELossLessTransferSyntax()) { - bool res = (bool)gdcm_read_RLE_file (fp,destination); - return res; + bool res = (bool)gdcm_read_RLE_file (fp,destination); + Header->CloseFile(); + return res; } // --------------- SingleFrame/Multiframe JPEG Lossless/Lossy/2000 int nb; - std::string str_nb=Header->GetPubEntryByNumber(0x0028,0x0100); + std::string str_nb=Header->GetEntryByNumber(0x0028,0x0100); if (str_nb == GDCM_UNFOUND ) { nb = 16; } else { @@ -847,7 +849,7 @@ bool gdcmFile::ReadPixelData(void* destination) { int taille = Header->GetXSize() * Header->GetYSize() * Header->GetSamplesPerPixel(); long fragmentBegining; // for ftell, fseek - + bool jpg2000 = Header->IsJPEG2000(); bool jpgLossless = Header->IsJPEGLossless(); @@ -855,7 +857,7 @@ bool gdcmFile::ReadPixelData(void* destination) { guint16 ItemTagGr,ItemTagEl; int ln; - // Position on begining of Jpeg Pixels + // Position on begining of Jpeg Pixels fread(&ItemTagGr,2,1,fp); // Reading (fffe) : Item Tag Gr fread(&ItemTagEl,2,1,fp); // Reading (e000) : Item Tag El @@ -882,7 +884,7 @@ bool gdcmFile::ReadPixelData(void* destination) { } // parsing fragments until Sequence Delim. Tag found - while ( ( ItemTagGr == 0xfffe) && (ItemTagEl != 0xe0dd) ) { + while ( ( ItemTagGr == 0xfffe) && (ItemTagEl != 0xe0dd) ) { // --- for each Fragment fread(&ln,4,1,fp);