]> Creatis software - gdcm.git/commitdiff
Replace the DEBUG on the stack with a global entry in cmake interface:
authormalaterre <malaterre>
Mon, 3 May 2004 03:30:39 +0000 (03:30 +0000)
committermalaterre <malaterre>
Mon, 3 May 2004 03:30:39 +0000 (03:30 +0000)
       GDCM_DEBUG, so you can turn verbosity ON/OFF for debug statement.

CMakeLists.txt
ChangeLog
gdcmConfigure.h.in
src/gdcmDebug.h
src/gdcmHeader.cxx
src/gdcmJpeg.cxx
src/gdcmJpeg12.cxx

index 9bf969e28f4cccc05e138e5d07913a4000a179b9..cd260e9167ee64fcee8a8f9f74cb7f2c06377a10 100644 (file)
@@ -20,6 +20,7 @@ MARK_AS_ADVANCED(GDCM_DATA_DIR)
 OPTION(BUILD_SHARED_LIBS "Build GDCM with shared libraries." ON)\r
 SET(GDCM_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})\r
 \r
+OPTION(GDCM_DEBUG "Turn verbosity of some statement ON." OFF)\r
 \r
 #-----------------------------------------------------------------------------\r
 SET (EXECUTABLE_OUTPUT_PATH ${GDCM_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")\r
index 813b1e90f65f407c79963382d317b23518de94e7..38b881b00bebf677fa618247ccbae0df92cc1b9c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
      * Add a new test: ShowDicom, for now this is just the c++ version of
        checkRead.sh, later it will be able to compare the image read against a
        baseline.
+     * Replace the DEBUG on the stack with a global entry in cmake interface:
+       GDCM_DEBUG, so you can turn verbosity ON/OFF for debug statement.
 
 2004-04-30  Mathieu Malaterre  <Mathieu.Malaterre@creatis.insa-lyon.fr>
      * Add an example subdir, with a real example on how to read + write a 
index 8d856d4bf0d48da9506d62ee0429048b1480bc1c..08856ac9cd87d092643ef0879f74c24c27bf2723 100644 (file)
@@ -8,4 +8,4 @@
 
 #cmakedefine HAVE_NO_STDINT_H 
 
-
+#cmakedefine GDCM_DEBUG
index 886e2ec4e5dca24f8f3c4c20749ff4a0c283a6b2..86a2002203cc564cba8308fcc4376a43f0ac895d 100644 (file)
@@ -3,8 +3,6 @@
 #ifndef GDCMDEBUG_H
 #define GDCMDEBUG_H
 
-#define GDCM_DEBUG -1
-
 /**
  * \ingroup gdcmDebug
  * \brief gdcmDebug is an object for debugging in program.
@@ -18,7 +16,7 @@
  */
 class gdcmDebug {
 public:
-   gdcmDebug(int level = GDCM_DEBUG);
+   gdcmDebug(int level = -1);
 
    void SetDebug (int level);
    void Verbose(int, const char*, const char* ="");
index bc3b906abf1952fcede37414cf280210999f204a..f0f68468a31121b32d3504847d2552a699c6704a 100644 (file)
@@ -1,16 +1,13 @@
 // gdcmHeader.cxx
 //-----------------------------------------------------------------------------
-#include <stdio.h>
-#include <cerrno>
-#include <cctype>    // for isalpha
-#include <vector>
-
 #include "gdcmHeader.h"
 #include "gdcmGlobal.h"
 #include "gdcmUtil.h"
 #include "gdcmDebug.h"
 #include "gdcmTS.h"
 
+#include <vector>
+
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
 /**
@@ -46,25 +43,25 @@ gdcmHeader::gdcmHeader(const char *InFilename,
    
    // This IS the right place for the code
  
-      std::string ImageLocation = GetEntryByNumber(0x0028, 0x0200);
-      if ( ImageLocation == GDCM_UNFOUND ) { // Image Location
-         GrPixel = 0x7fe0;                   // default value
-      } else {
-         GrPixel = (guint16) atoi( ImageLocation.c_str() );
-      }   
-      if (GrPixel == 0xe07f) // sometimes Image Location value doesn't follow 
-         GrPixel = 0x7fe0;   // the supposed processor endianity. 
-                             // see gdcmData/cr172241.dcm      
-      if (GrPixel != 0x7fe0) 
-         // This is a kludge for old dirty Philips imager.
-         NumPixel = 0x1010;
-      else
-         NumPixel = 0x0010;
+   std::string ImageLocation = GetEntryByNumber(0x0028, 0x0200);
+   if ( ImageLocation == GDCM_UNFOUND ) { // Image Location
+      GrPixel = 0x7fe0;                   // default value
+   } else {
+      GrPixel = (guint16) atoi( ImageLocation.c_str() );
+   }   
+   if (GrPixel == 0xe07f) // sometimes Image Location value doesn't follow 
+      GrPixel = 0x7fe0;   // the supposed processor endianity. 
+                          // see gdcmData/cr172241.dcm      
+   if (GrPixel != 0x7fe0) 
+      // This is a kludge for old dirty Philips imager.
+      NumPixel = 0x1010;
+   else
+      NumPixel = 0x0010;
 
-      TagKey key = gdcmDictEntry::TranslateToKey(GrPixel, NumPixel);
-      countGrPixel = GetEntry().count(key);
+   TagKey key = gdcmDictEntry::TranslateToKey(GrPixel, NumPixel);
+   countGrPixel = GetEntry().count(key);
       
-      // we set the SQ Depth of each Header Entry
+   // we set the SQ Depth of each Header Entry
    
    int top =-1;
    int countSQ = 0;      
@@ -75,97 +72,104 @@ gdcmHeader::gdcmHeader(const char *InFilename,
    std::ostringstream tab; 
    tab << "   ";
    
-   int DEBUG = 0;  // Sorry; Dealing with e-film breaker images
-                   // will (certainly) cause a lot of troubles ...
-                   // I prefer keeping my 'trace' on .            
+   // GDCM_DEBUG
+   // Sorry; Dealing with e-film breaker images
+   // will (certainly) cause a lot of troubles ...
+   // I prefer keeping my 'trace' on .            
    
    for (ListTag::iterator i = listEntries.begin();  
-       i != listEntries.end();
-       ++i) {
-      (*i)->SetSQDepthLevel(countSQ);
-      if ( (*i)->GetVR() == "SQ" && (*i)->GetReadLength() != 0) {   // SQ found         
-         countSQ++;
-        top ++;         
-           if ( top >= 20) {
+      i != listEntries.end();
+      ++i) {
+         (*i)->SetSQDepthLevel(countSQ);
+         if ( (*i)->GetVR() == "SQ" && (*i)->GetReadLength() != 0) {   // SQ found         
+            countSQ++;
+            top ++;     
+            if ( top >= 20) {
+#ifdef GDCM_DEBUG
                std::cout << "Kaie ! Kaie! SQ Stack Overflow" << std::endl;
-              return;
+#endif //GDCM_DEBUG
+               return;
             }
-        if (DEBUG) std::cout << "\n >>>>> empile niveau " << top 
-                        << "; Lgr SeQ: " << (*i)->GetReadLength() 
-                         << "\n" <<std::endl;
-                
-        pile[top].totalSQlength = (*i)->GetReadLength();
-        pile[top].alreadyParsedlength = 0; 
-        currentParsedlength = 0;                      
-
-      } else {                              // non SQ found
-      
-         if (countSQ != 0) {                // we are 'inside a SeQuence'
-            if ( (*i)->GetGroup()==0xfffe  && (*i)->GetElement()==0xe0dd){
-              // we just found 'end of SeQuence'
-               
-              if (DEBUG)
-                   std::cout << "fffe,e0dd : depile" << std::endl;
+#ifdef GDCM_DEBUG
+            std::cout << "\n >>>>> empile niveau " << top 
+               << "; Lgr SeQ: " << (*i)->GetReadLength() 
+               << "\n" <<std::endl;
+#endif //GDCM_DEBUG
+
+            pile[top].totalSQlength = (*i)->GetReadLength();
+            pile[top].alreadyParsedlength = 0; 
+            currentParsedlength = 0;                  
+
+         } else {  // non SQ found
+         if (countSQ != 0) { // we are 'inside a SeQuence'
+            if ( (*i)->GetGroup()==0xfffe  && (*i)->GetElement()==0xe0dd) {
+               // we just found 'end of SeQuence'
+
+#ifdef GDCM_DEBUG
+               std::cout << "fffe,e0dd : depile" << std::endl;
+#endif //GDCM_DEBUG
+
                currentParsedlength += 8; // gr:2 elem:2 vr:2 lgt:2                                    
-              countSQ --;
+               countSQ --;
                top --; 
                pile[top].alreadyParsedlength +=  currentParsedlength;
             } else {
-              // we are on a 'standard' elem
-              // or a Zero-length SeQuence
-              
-              totalElementlength =  (*i)->GetFullLength();            
-              currentParsedlength += totalElementlength;                                
+               // we are on a 'standard' elem
+               // or a Zero-length SeQuence
+
+               totalElementlength =  (*i)->GetFullLength();           
+               currentParsedlength += totalElementlength;                               
                pile[top].alreadyParsedlength += totalElementlength;
-              
+
                if (pile[top].totalSQlength == 0xffffffff) {
-                  if (DEBUG)
-                    std::cout << "totalSeQlength == 0xffffffff" 
-                               << std::endl; 
+#ifdef GDCM_DEBUG
+                  std::cout << "totalSeQlength == 0xffffffff" << std::endl; 
+#endif //GDCM_DEBUG
                } else {
-                 if (DEBUG) 
-                       std::cout << "alrdyPseLgt:"
-                      << pile[top].alreadyParsedlength << " totSeQlgt: " 
-                      << pile[top].totalSQlength << " curPseLgt: " 
-                      << currentParsedlength
-                      << std::endl;
+#ifdef GDCM_DEBUG
+                  std::cout << "alrdyPseLgt:"
+                   << pile[top].alreadyParsedlength << " totSeQlgt: " 
+                   << pile[top].totalSQlength << " curPseLgt: " 
+                   << currentParsedlength
+                   << std::endl;
+#endif //GDCM_DEBUG
                   while (pile[top].alreadyParsedlength==pile[top].totalSQlength) {
-                 
-                    if (DEBUG) 
-                         std::cout << " \n<<<<<< On depile niveau " << top 
-                                   << " \n" <<  std::endl;
-                     (*i)->SetSQDepthLevel(countSQ);                
-                     currentParsedlength = pile[top].alreadyParsedlength;
-                     countSQ --;
-                     top --;
-                    if (top >=0) {
-                       
-                        pile[top].alreadyParsedlength +=  currentParsedlength +12;
-                                               // 12 : length of 'SQ embedded' SQ element
-                        currentParsedlength += 8; // gr:2 elem:2 vr:2 lgt:2
-                                                                                            
-                       if (DEBUG)
-                             std::cout << pile[top].alreadyParsedlength << " " 
-                                       << pile[top].totalSQlength << " " 
-                                       << currentParsedlength
-                                       << std::endl;
-                     }                              
-                    if (top == -1) {
-                        currentParsedlength = 0;
-                        break;
-                     }                                                      
+#ifdef GDCM_DEBUG
+                  std::cout << " \n<<<<<< On depile niveau " << top 
+                     << " \n" <<  std::endl;
+#endif //GDCM_DEBUG
+                  (*i)->SetSQDepthLevel(countSQ);                   
+                  currentParsedlength = pile[top].alreadyParsedlength;
+                  countSQ --;
+                  top --;
+                  if (top >=0) {
+                     pile[top].alreadyParsedlength +=  currentParsedlength +12;
+                     // 12 : length of 'SQ embedded' SQ element
+                     currentParsedlength += 8; // gr:2 elem:2 vr:2 lgt:2
+
+#ifdef GDCM_DEBUG
+                     std::cout << pile[top].alreadyParsedlength << " " 
+                       << pile[top].totalSQlength << " " 
+                       << currentParsedlength
+                       << std::endl;
+#endif //GDCM_DEBUG
                   }
-               }                               
-            }              
-         }   // end : 'inside a SeQuence'   
-      } 
-      if (DEBUG) {
-         for (int k=0; k<(*i)->GetSQDepthLevel();k++) {
-           std::cout << tab;
-         }
-        (*i)->SetPrintLevel(2);
-        (*i)->Print();
-      }      
+                  if (top == -1) {
+                     currentParsedlength = 0;
+                     break;
+                  }
+               }
+            }                          
+         }              
+      }   // end : 'inside a SeQuence'   
+   } 
+#ifdef GDCM_DEBUG
+   for (int k=0; k<(*i)->GetSQDepthLevel();k++) {
+      std::cout << tab;
+   }
+   (*i)->SetPrintLevel(2);
+   (*i)->Print();
+#endif //GDCM_DEBUG
    } // end for        
 }
 
@@ -620,9 +624,11 @@ size_t gdcmHeader::GetPixelOffset(void) {
    if (PixelElement) {
       return PixelElement->GetOffset();
    } else {
-/*      std::cout << "Big trouble : Pixel Element ("
+#ifdef GDCM_DEBUG
+      std::cout << "Big trouble : Pixel Element ("
                 << std::hex << GrPixel<<","<< NumPixel<< ") NOT found"
-                << std::endl;  */
+                << std::endl;  
+#endif //GDCM_DEBUG
       return 0;
    }     
 }
@@ -649,10 +655,11 @@ size_t gdcmHeader::GetPixelAreaLength(void) {
    if (PixelElement) {
       return PixelElement->GetLength();
    } else {
-/*      std::cout << "Big trouble : Pixel Element ("
+#ifdef GDCM_DEBUG
+      std::cout << "Big trouble : Pixel Element ("
                 << std::hex << GrPixel<<","<< NumPixel<< ") NOT found"
                 << std::endl;
-*/
+#endif //GDCM_DEBUG
       return 0;
    }
 }
index c2b93070ac28ff1836fa12d6afdf175ff294d3c0..640522d97487363cbae36852c6bb2efaf981ea04 100644 (file)
@@ -5,8 +5,6 @@
 
 #define BITS_IN_JSAMPLE 8
 
-#define DEBUG 0
-
 /*
 DICOM provides a mechanism for supporting the use of JPEG Image Compression 
 through the Encapsulated Format (see PS 3.3 of the DICOM Standard). 
@@ -191,7 +189,9 @@ bool gdcmFile::gdcm_read_JPEG_file (FILE *fp,void * image_buffer) {
 
    int row_stride;             /* physical row width in output buffer */
   
-   if (DEBUG) printf("entree dans gdcmFile::gdcm_read_JPEG_file12, depuis gdcmJpeg\n");
+#ifdef GDCM_DEBUG
+   printf("entree dans gdcmFile::gdcm_read_JPEG_file12, depuis gdcmJpeg\n");
+#endif //GDCM_DEBUG
 
    /* In this example we want to open the input file before doing anything else,
     * so that the setjmp() error recovery below can assume the file is open.
@@ -200,7 +200,9 @@ bool gdcmFile::gdcm_read_JPEG_file (FILE *fp,void * image_buffer) {
     */
     
   /* Step 1: allocate and initialize JPEG decompression object */  
-  if (DEBUG)printf("Entree Step 1\n");
+#ifdef GDCM_DEBUG
+  printf("Entree Step 1\n");
+#endif //GDCM_DEBUG
   
   /* We set up the normal JPEG error routines, then override error_exit. */
   
@@ -219,12 +221,16 @@ bool gdcmFile::gdcm_read_JPEG_file (FILE *fp,void * image_buffer) {
   jpeg_create_decompress(&cinfo);
 
    /* Step 2: specify data source (eg, a file) */
-   if (DEBUG) printf("Entree Step 2\n");
+#ifdef GDCM_DEBUG
+  printf("Entree Step 2\n");
+#endif //GDCM_DEBUG
 
    jpeg_stdio_src(&cinfo, fp);
 
    /* Step 3: read file parameters with jpeg_read_header() */
-   if (DEBUG) printf("Entree Step 3\n");
+#ifdef GDCM_DEBUG
+  printf("Entree Step 3\n");
+#endif //GDCM_DEBUG
 
    (void) jpeg_read_header(&cinfo, TRUE);
    
@@ -234,7 +240,7 @@ bool gdcmFile::gdcm_read_JPEG_file (FILE *fp,void * image_buffer) {
     * See libjpeg.doc for more info.
     */
 
-   if (DEBUG) {   
+#ifdef GDCM_DEBUG
       printf("--------------Header contents :----------------\n");
       printf("image_width %d image_height %d\n", 
               cinfo.image_width , cinfo.image_height);
@@ -242,7 +248,7 @@ bool gdcmFile::gdcm_read_JPEG_file (FILE *fp,void * image_buffer) {
               cinfo.output_components);
       printf("nb of color components returned  %d \n", 
               cinfo.data_precision);
-   }
+#endif //GDCM_DEBUG
 
 
    /*
@@ -255,13 +261,17 @@ bool gdcmFile::gdcm_read_JPEG_file (FILE *fp,void * image_buffer) {
     */
 
    /* Step 4: set parameters for decompression */
-   if (DEBUG) printf("Entree Step 4\n");
+#ifdef GDCM_DEBUG
+  printf("Entree Step 4\n");
+#endif //GDCM_DEBUG
    /* In this example, we don't need to change any of the defaults set by
     * jpeg_read_header(), so we do nothing here.
     */
 
    /* Step 5: Start decompressor */
-   if (DEBUG) printf("Entree Step 5\n");
+#ifdef GDCM_DEBUG
+   printf("Entree Step 5\n");
+#endif GDCM_DEBUG
 
    (void) jpeg_start_decompress(&cinfo);
    /* We can ignore the return value since suspension is not possible
@@ -278,25 +288,28 @@ bool gdcmFile::gdcm_read_JPEG_file (FILE *fp,void * image_buffer) {
    /* JSAMPLEs per row in output buffer */
    row_stride = cinfo.output_width * cinfo.output_components;
   
-   if (DEBUG) printf ("cinfo.output_width %d cinfo.output_components %d  row_stride %d\n",
+#ifdef GDCM_DEBUG
+  printf ("cinfo.output_width %d cinfo.output_components %d  row_stride %d\n",
                       cinfo.output_width, cinfo.output_components,row_stride);
-       
+#endif //GDCM_DEBUG
+
    /* Make a one-row-high sample array that will go away when done with image */
    buffer = (*cinfo.mem->alloc_sarray)
             ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
 
    /* Step 6: while (scan lines remain to be read) */
-   if (DEBUG)  printf("Entree Step 6\n"); 
-
+#ifdef GDCM_DEBUG
+    printf("Entree Step 6\n"); 
+#endif //GDCM_DEBUG
    /*           jpeg_read_scanlines(...); */
 
    /* Here we use the library's state variable cinfo.output_scanline as the
     * loop counter, so that we don't have to keep track ourselves.
     */
-   if (DEBUG)  
+#ifdef GDCM_DEBUG
       printf ("cinfo.output_height %d  cinfo.output_width %d\n",
                cinfo.output_height,cinfo.output_width);
+#endif //GDCM_DEBUG
    pimage=(char *)image_buffer;
   
    while (cinfo.output_scanline < cinfo.output_height) {
@@ -323,7 +336,10 @@ bool gdcmFile::gdcm_read_JPEG_file (FILE *fp,void * image_buffer) {
   }
  
   /* Step 7: Finish decompression */
-   if (DEBUG)  printf("Entree Step 7\n");
+#ifdef GDCM_DEBUG
+   printf("Entree Step 7\n");
+#endif //GDCM_DEBUG
+
    (void) jpeg_finish_decompress(&cinfo);
    
    /* We can ignore the return value since suspension is not possible
@@ -332,7 +348,9 @@ bool gdcmFile::gdcm_read_JPEG_file (FILE *fp,void * image_buffer) {
 
    /* Step 8: Release JPEG decompression object */
 
-   if (DEBUG) printf("Entree Step 8\n");
+#ifdef GDCM_DEBUG
+  printf("Entree Step 8\n");
+#endif //GDCM_DEBUG
 
    /* This is an important step since it will release a good deal of memory. */
 
index e8b0b8b0a665b7ad32f1a3aada7987821d0b0a32..6b84a9579e214cb1896333a1df9b6976d809fb67 100644 (file)
@@ -5,8 +5,6 @@
 
 #define BITS_IN_JSAMPLE 12
 
-#define DEBUG 0
-
 // BITS_IN_JSAMPLE is a compile time defined options.
 // We need both 8 an 12;
 // To avoid renaming *all* the Jpeg functions,
@@ -203,8 +201,9 @@ bool gdcmFile::gdcm_read_JPEG_file12 (FILE *fp,void * image_buffer) {
    // typedef JSAMPARRAY *JSAMPIMAGE;  /* a 3-D sample array: top index is color */
 
    int row_stride;             /* physical row width in output buffer */
-  
-   if (DEBUG) printf("entree dans gdcmFile::gdcm_read_JPEG_file12, depuis gdcmJpeg\n");
+#ifdef GDCM_DEBUG
+   printf("entree dans gdcmFile::gdcm_read_JPEG_file12, depuis gdcmJpeg\n");
+#endif //GDCM_DEBUG
 
    /* In this example we want to open the input file before doing anything else,
     * so that the setjmp() error recovery below can assume the file is open.
@@ -213,7 +212,9 @@ bool gdcmFile::gdcm_read_JPEG_file12 (FILE *fp,void * image_buffer) {
     */
 
    /* Step 1: allocate and initialize JPEG decompression object */
-   if (DEBUG)printf("Entree Step 1\n");
+#ifdef GDCM_DEBUG
+   printf("Entree Step 1\n");
+#endif //GDCM_DEBUG
 
    /* We set up the normal JPEG error routines, then override error_exit. */
 
@@ -233,11 +234,15 @@ bool gdcmFile::gdcm_read_JPEG_file12 (FILE *fp,void * image_buffer) {
    jpeg_create_decompress(&cinfo);
 
    /* Step 2: specify data source (eg, a file) */
-   if (DEBUG) printf("Entree Step 2\n");
+#ifdef GDCM_DEBUG
+   printf("Entree Step 2\n");
+#endif //GDCM_DEBUG
    jpeg_stdio_src(&cinfo, fp);
 
    /* Step 3: read file parameters with jpeg_read_header() */
-   if (DEBUG) printf("Entree Step 3\n");
+#ifdef GDCM_DEBUG
+   printf("Entree Step 3\n");
+#endif //GDCM_DEBUG
    (void) jpeg_read_header(&cinfo, TRUE);
 
    /* We can ignore the return value from jpeg_read_header since
@@ -246,7 +251,7 @@ bool gdcmFile::gdcm_read_JPEG_file12 (FILE *fp,void * image_buffer) {
     * See libjpeg.doc for more info.
     */
 
-   if (DEBUG) {   
+#ifdef GDCM_DEBUG
       printf("--------------Header contents :----------------\n");
       printf("image_width %d image_height %d\n", 
               cinfo.image_width , cinfo.image_height);
@@ -254,7 +259,7 @@ bool gdcmFile::gdcm_read_JPEG_file12 (FILE *fp,void * image_buffer) {
               cinfo.output_components);
       printf("nb of color components returned  %d \n", 
               cinfo.data_precision);
-   }
+#endif //GDCM_DEBUG
 
 
    /*
@@ -267,14 +272,18 @@ bool gdcmFile::gdcm_read_JPEG_file12 (FILE *fp,void * image_buffer) {
     */
 
    /* Step 4: set parameters for decompression */
-   if (DEBUG) printf("Entree Step 4\n");
+#ifdef GDCM_DEBUG
+   printf("Entree Step 4\n");
+#endif //GDCM_DEBUG
 
    /* In this example, we don't need to change any of the defaults set by
     * jpeg_read_header(), so we do nothing here.
     */
 
    /* Step 5: Start decompressor */
-   if (DEBUG) printf("Entree Step 5\n");
+#ifdef GDCM_DEBUG
+   printf("Entree Step 5\n");
+#endif //GDCM_DEBUG
 
    (void) jpeg_start_decompress(&cinfo);
    /* We can ignore the return value since suspension is not possible
@@ -291,16 +300,19 @@ bool gdcmFile::gdcm_read_JPEG_file12 (FILE *fp,void * image_buffer) {
    /* JSAMPLEs per row in output buffer */
    row_stride = cinfo.output_width * cinfo.output_components;
   
-   if (DEBUG) 
+#ifdef GDCM_DEBUG
       printf ("cinfo.output_width %d cinfo.output_components %d  row_stride %d\n",
               cinfo.output_width, cinfo.output_components,row_stride);
-       
+#endif //GDCM_DEBUG
+
    /* Make a one-row-high sample array that will go away when done with image */
    buffer = (*cinfo.mem->alloc_sarray)
            ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
 
    /* Step 6: while (scan lines remain to be read) */
-   if (DEBUG)  printf("Entree Step 6\n"); 
+#ifdef GDCM_DEBUG
+   printf("Entree Step 6\n"); 
+#endif //GDCM_DEBUG
 
    /*           jpeg_read_scanlines(...); */
 
@@ -308,8 +320,10 @@ bool gdcmFile::gdcm_read_JPEG_file12 (FILE *fp,void * image_buffer) {
     * loop counter, so that we don't have to keep track ourselves.
     */
 
-   if (DEBUG)  printf ("cinfo.output_height %d  cinfo.output_width %d\n",
+#ifdef GDCM_DEBUG
+   printf ("cinfo.output_height %d  cinfo.output_width %d\n",
                       cinfo.output_height,cinfo.output_width);
+#endif //GDCM_DEBUG
 
    pimage=(char *)image_buffer;
 
@@ -331,14 +345,18 @@ bool gdcmFile::gdcm_read_JPEG_file12 (FILE *fp,void * image_buffer) {
    }
  
   /* Step 7: Finish decompression */
-   if (DEBUG)  printf("Entree Step 7\n");
+#ifdef GDCM_DEBUG
+   printf("Entree Step 7\n");
+#endif //GDCM_DEBUG
    (void) jpeg_finish_decompress(&cinfo);
    /* We can ignore the return value since suspension is not possible
     * with the stdio data source.
     */
 
    /* Step 8: Release JPEG decompression object */
-   if (DEBUG) printf("Entree Step 8\n");
+#ifdef GDCM_DEBUG
+   printf("Entree Step 8\n");
+#endif //GDCM_DEBUG
 
    /* This is an important step since it will release a good deal of memory. */
    jpeg_destroy_decompress(&cinfo);