X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmParsePixels.cxx;h=078884d9c0eb4c120b733a9ecbb6ef52405de566;hb=7815fe9dc3532b716dc478ca0f255263f99d296f;hp=c388cb541d27bae7f53e240809a98b8847112e08;hpb=3c4f36672d0c3dff9079817614d62604f9e22827;p=gdcm.git diff --git a/src/gdcmParsePixels.cxx b/src/gdcmParsePixels.cxx index c388cb54..078884d9 100644 --- a/src/gdcmParsePixels.cxx +++ b/src/gdcmParsePixels.cxx @@ -1,19 +1,23 @@ -// gdcmParse.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 - +/*========================================================================= + + Program: gdcm + Module: $RCSfile: gdcmParsePixels.cxx,v $ + Language: C++ + Date: $Date: 2004/07/17 22:47:01 $ + Version: $Revision: 1.9 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "gdcmCommon.h" #include "gdcmFile.h" -#include "gdcmUtil.h" #define str2num(str, typeNum) *((typeNum *)(str)) @@ -58,16 +62,16 @@ bool gdcmFile::ParsePixelData(void) { nb = atoi(str_nb.c_str() ); if (nb == 12) nb =16; } - int nBytes= nb/8; + //int nBytes= nb/8; //FIXME - int taille = Header->GetXSize() * Header->GetYSize() * Header->GetSamplesPerPixel(); + //int taille = Header->GetXSize() * Header->GetYSize() * Header->GetSamplesPerPixel(); printf ("Checking the Dicom-encapsulated Jpeg/RLE Pixels\n"); - guint16 ItemTagGr,ItemTagEl; + uint16_t ItemTagGr,ItemTagEl; int ln; long ftellRes; - char * destination = NULL; + //char * destination = NULL; // -------------------- for Parsing : Position on begining of Jpeg/RLE Pixels @@ -82,20 +86,20 @@ bool gdcmFile::ParsePixelData(void) { ItemTagEl=Header->SwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000): %04x,%04x\n", - ftellRes,ItemTagGr,ItemTagEl ); + (unsigned)ftellRes,ItemTagGr,ItemTagEl ); ftellRes=ftell(fp); fread(&ln,4,1,fp); if(Header->GetSwapCode()) - ln=Header->SwapLong(ln); // Basic Offset Table Item Lentgh - printf("at %x : Basic Offset Table Item Lentgh (??) %d x(%08x)\n", - ftellRes,ln,ln); + ln=Header->SwapLong(ln); // Basic Offset Table Item Length + printf("at %x : Basic Offset Table Item Length (\?\?) %d x(%08x)\n", + (unsigned)ftellRes,ln,ln); if (ln != 0) { // What is it used for ?? - char * BasicOffsetTableItemValue= (char *)malloc(ln+1); + char * BasicOffsetTableItemValue= new char[ln+1]; fread(BasicOffsetTableItemValue,ln,1,fp); - guint32 a; + uint32_t a; for (int i=0;iSwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000 or e0dd): %04x,%04x\n", - ftellRes,ItemTagGr,ItemTagEl ); + (unsigned)ftellRes,ItemTagGr,ItemTagEl ); while ( ( ItemTagGr==0xfffe) && (ItemTagEl!=0xe0dd) ) { // Parse fragments @@ -117,7 +121,7 @@ bool gdcmFile::ParsePixelData(void) { if(Header->GetSwapCode()) ln=Header->SwapLong(ln); // length printf(" at %x : fragment length %d x(%08x)\n", - ftellRes, ln,ln); + (unsigned)ftellRes, ln,ln); // destination += taille * nBytes; // location in user's memory //printf (" Destination will be x(%x) = %d \n", @@ -135,15 +139,15 @@ bool gdcmFile::ParsePixelData(void) { ItemTagEl=Header->SwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000 or e0dd): %04x,%04x\n", - ftellRes,ItemTagGr,ItemTagEl ); + (unsigned)ftellRes,ItemTagGr,ItemTagEl ); } } else { // RLE Image long RleSegmentLength[15],fragmentLength; - guint32 nbRleSegments; - guint32 RleSegmentOffsetTable[15]; + uint32_t nbRleSegments; + uint32_t RleSegmentOffsetTable[15]; ftellRes=ftell(fp); // Basic Offset Table with Item Value // Item Tag @@ -154,21 +158,21 @@ bool gdcmFile::ParsePixelData(void) { ItemTagEl=Header->SwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000): %04x,%04x\n", - ftellRes,ItemTagGr,ItemTagEl ); + (unsigned)ftellRes,ItemTagGr,ItemTagEl ); // Item Length ftellRes=ftell(fp); fread(&ln,4,1,fp); if(Header->GetSwapCode()) - ln=Header->SwapLong(ln); // Basic Offset Table Item Lentgh - printf("at %x : Basic Offset Table Item Lentgh (??) %d x(%08x)\n", - ftellRes,ln,ln); + ln=Header->SwapLong(ln); // Basic Offset Table Item Length + printf("at %x : Basic Offset Table Item Length (\?\?) %d x(%08x)\n", + (unsigned)ftellRes,ln,ln); if (ln != 0) { // What is it used for ?? - char * BasicOffsetTableItemValue= (char *)malloc(ln+1); + char * BasicOffsetTableItemValue= new char[ln+1]; fread(BasicOffsetTableItemValue,ln,1,fp); - guint32 a; + uint32_t a; for (int i=0;iSwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000 or e0dd): %04x,%04x\n", - ftellRes,ItemTagGr,ItemTagEl ); + (unsigned)ftellRes,ItemTagGr,ItemTagEl ); // while 'Sequence Delimiter Item' (fffe,e0dd) not found while ( ( ItemTagGr == 0xfffe) && (ItemTagEl != 0xe0dd) ) { @@ -191,7 +195,7 @@ bool gdcmFile::ParsePixelData(void) { if(Header->GetSwapCode()) fragmentLength=Header->SwapLong(fragmentLength); // length printf(" at %x : 'fragment' length %d x(%08x)\n", - ftellRes, fragmentLength,fragmentLength); + (unsigned)ftellRes, (unsigned)fragmentLength,(unsigned)fragmentLength); //------------------ scanning (not reading) fragment pixels @@ -206,17 +210,17 @@ bool gdcmFile::ParsePixelData(void) { if(Header->GetSwapCode()) RleSegmentOffsetTable[k]=Header->SwapLong(RleSegmentOffsetTable[k]); printf(" at : %x Offset Segment %d : %d (%x)\n", - ftellRes,k,RleSegmentOffsetTable[k], + (unsigned)ftellRes,k,RleSegmentOffsetTable[k], RleSegmentOffsetTable[k]); } if (nbRleSegments>1) { // skipping (not reading) RLE Segments - for(int k=1; k<=nbRleSegments-1; k++) { + for(unsigned int k=1; k<=nbRleSegments-1; k++) { RleSegmentLength[k]= RleSegmentOffsetTable[k+1] - RleSegmentOffsetTable[k]; ftellRes=ftell(fp); printf (" Segment %d : Length = %d x(%x) Start at %x\n", - k,RleSegmentLength[k],RleSegmentLength[k], ftellRes); + k,(unsigned)RleSegmentLength[k],(unsigned)RleSegmentLength[k], (unsigned)ftellRes); fseek(fp,RleSegmentLength[k],SEEK_CUR); } } @@ -224,8 +228,8 @@ bool gdcmFile::ParsePixelData(void) { - RleSegmentOffsetTable[nbRleSegments]; ftellRes=ftell(fp); printf (" Segment %d : Length = %d x(%x) Start at %x\n", - nbRleSegments,RleSegmentLength[nbRleSegments], - RleSegmentLength[nbRleSegments],ftellRes); + nbRleSegments,(unsigned)RleSegmentLength[nbRleSegments], + (unsigned)RleSegmentLength[nbRleSegments],(unsigned)ftellRes); fseek(fp,RleSegmentLength[nbRleSegments],SEEK_CUR); @@ -239,7 +243,7 @@ bool gdcmFile::ParsePixelData(void) { ItemTagEl=Header->SwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000 or e0dd): %04x,%04x\n", - ftellRes,ItemTagGr,ItemTagEl ); + (unsigned)ftellRes,ItemTagGr,ItemTagEl ); } } return true;