]> Creatis software - gdcm.git/commitdiff
ENH: minor style issue
authormalaterre <malaterre>
Fri, 8 Oct 2004 17:24:54 +0000 (17:24 +0000)
committermalaterre <malaterre>
Fri, 8 Oct 2004 17:24:54 +0000 (17:24 +0000)
- gdcmFile: Move 12bits into separate ifelse to be able to fail properly

src/gdcmFile.cxx
src/gdcmJpeg12.cxx
src/gdcmJpeg8.cxx

index 323cdba54346ab1add3ab41eb4006c14a11459e3..2defabdaebfcadf3c4ec6046467059cda33038c6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/10/08 17:02:53 $
-  Version:   $Revision: 1.136 $
+  Date:      $Date: 2004/10/08 17:24:54 $
+  Version:   $Revision: 1.137 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -1068,11 +1068,17 @@ bool gdcmFile::ReadPixelData(void* destination)
             // Reading Fragment pixels
             res = gdcm_read_JPEG_file (fp,destination);
          }
-         else
+         else if ( Header->GetBitsStored() == 12)
          {
             // Reading Fragment pixels
             res = gdcm_read_JPEG_file12 (fp,destination);
          }
+         else
+         {
+            // other JPEG lossy not supported
+            dbg.Error(" gdcmFile::ReadPixelData : unknown jpeg lossy compression");
+            return 0;
+         }
          // ------------------------------------- endif (JPEGLossy)
       }
 
index 18d0787c184404ed5ef2fe9c55510928cad76eff..1b8ae574319582c2358ddd0c6b2943e9babb64ff 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmJpeg12.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/10/08 04:52:55 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2004/10/08 17:24:54 $
+  Version:   $Revision: 1.18 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -32,7 +32,7 @@
  */
 
 extern "C" {
-#include <stdio.h>
+//#include <stdio.h>
 #include "src/jpeg/libijg12/jconfig.h"
 #include "src/jpeg/libijg12/jpeglib.h"
 //#include "jconfig12.h"
@@ -107,7 +107,8 @@ typedef struct my_error_mgr * my_error_ptr;
 /*
  * Here's the routine that will replace the standard error_exit method:
  */
-METHODDEF(void) my_error_exit (j_common_ptr cinfo) {
+METHODDEF(void) my_error_exit (j_common_ptr cinfo)
+{
    /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
    my_error_ptr myerr = (my_error_ptr) cinfo->err;
 
@@ -135,7 +136,8 @@ METHODDEF(void) my_error_exit (j_common_ptr cinfo) {
  * @return 1 on success, 0 on error
  */
  
-bool gdcmFile::gdcm_read_JPEG_file12 (FILE* fp,void* image_buffer) {
+bool gdcmFile::gdcm_read_JPEG_file12 (FILE* fp,void* image_buffer)
+{
    char *pimage;
 
    /* This struct contains the JPEG decompression parameters and pointers to
@@ -340,7 +342,7 @@ bool gdcmFile::gdcm_read_JPEG_file12 (FILE* fp,void* image_buffer) {
 
    /* And we're done! */
 
-   return(true);
+   return true;
 }
 
 /*
index 24b4f9e607fe17113de5b1cdd5e1fc72ab0a79be..8f0ad62f1807459af64ad49ab8358d5e2b3874b9 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmJpeg8.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/10/08 04:52:55 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2004/10/08 17:24:54 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -368,7 +368,8 @@ METHODDEF(void) my_error_exit (j_common_ptr cinfo) {
  * @return 1 on success, 0 on error
  */
  
-bool gdcmFile::gdcm_read_JPEG_file (FILE* fp, void* image_buffer) {
+bool gdcmFile::gdcm_read_JPEG_file (FILE* fp, void* image_buffer)
+{
    char* pimage;
 
    /* This struct contains the JPEG decompression parameters and pointers to
@@ -423,7 +424,8 @@ bool gdcmFile::gdcm_read_JPEG_file (FILE* fp, void* image_buffer) {
   jerr.pub.error_exit = my_error_exit;
   
   /* Establish the setjmp return context for my_error_exit to use. */  
-  if (setjmp(jerr.setjmp_buffer)) {
+  if (setjmp(jerr.setjmp_buffer))
+  {
     /* If we get here, the JPEG code has signaled an error.
      * We need to clean up the JPEG object, close the input file, and return.
      */
@@ -525,7 +527,8 @@ bool gdcmFile::gdcm_read_JPEG_file (FILE* fp, void* image_buffer) {
 #endif //GDCM_JPG_DEBUG
    pimage=(char *)image_buffer;
   
-   while (cinfo.output_scanline < cinfo.output_height) {
+   while (cinfo.output_scanline < cinfo.output_height)
+   {
       /* jpeg_read_scanlines expects an array of pointers to scanlines.
        * Here the array is only one element long, but you could ask for
        * more than one scanline at a time if that's more convenient.
@@ -535,14 +538,15 @@ bool gdcmFile::gdcm_read_JPEG_file (FILE* fp, void* image_buffer) {
      // on ecrit directement les pixels
      // (on DEVRAIT pouvoir)
     
-    //(void) jpeg_read_scanlines(&cinfo, pimage, 1);
-    
      (void) jpeg_read_scanlines(&cinfo, buffer, 1);
       
-     if ( BITS_IN_JSAMPLE == 8) {
+     if ( BITS_IN_JSAMPLE == 8)
+     {
          memcpy( pimage, buffer[0],row_stride); 
          pimage+=row_stride;
-     } else {
+     }
+     else
+     {
          memcpy( pimage, buffer[0],row_stride*2 ); // FIXME : *2  car 16 bits?!?
          pimage+=row_stride*2;                     // FIXME : *2 car 16 bits?!?     
      }
@@ -581,7 +585,7 @@ bool gdcmFile::gdcm_read_JPEG_file (FILE* fp, void* image_buffer) {
 
    /* And we're done! */
 
-   return(true);
+   return true;
 }