]> Creatis software - gdcm.git/blobdiff - src/gdcmParsePixels.cxx
BUG: very same bug when using char* instead of string
[gdcm.git] / src / gdcmParsePixels.cxx
index c95b825f5cf1c0b491b5918b145e2c70d6bebf8f..078884d9c0eb4c120b733a9ecbb6ef52405de566 100644 (file)
@@ -1,5 +1,21 @@
-// gdcmParse.cxx
-//-----------------------------------------------------------------------------
+/*=========================================================================
+                                                                                
+  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"
 
@@ -46,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 
 
@@ -70,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 Length
-      printf("at %x : Basic Offset Table Item Length (??) %d x(%08x)\n",
-            ftellRes,ln,ln);
+      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;i<ln;i+=4){
-            a=str2num(&BasicOffsetTableItemValue[i],guint32);
+            a=str2num(&BasicOffsetTableItemValue[i],uint32_t);
             printf("      x(%08x)  %d\n",a,a);
          }              
       }
@@ -96,7 +112,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 );
       
       while ( ( ItemTagGr==0xfffe) && (ItemTagEl!=0xe0dd) ) { // Parse fragments
       
@@ -105,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",
@@ -123,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
@@ -142,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 Length
-      printf("at %x : Basic Offset Table Item Length (??) %d x(%08x)\n",
-            ftellRes,ln,ln);
+      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;i<ln;i+=4){
-            a=str2num(&BasicOffsetTableItemValue[i],guint32);
+            a=str2num(&BasicOffsetTableItemValue[i],uint32_t);
             printf("      x(%08x)  %d\n",a,a);
          }              
       }
@@ -169,7 +185,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 );
 
       // while 'Sequence Delimiter Item' (fffe,e0dd) not found
       while (  ( ItemTagGr == 0xfffe) && (ItemTagEl != 0xe0dd) ) { 
@@ -179,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
  
@@ -194,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);    
              }
           }
@@ -212,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); 
             
@@ -227,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;