]> Creatis software - gdcm.git/commitdiff
BUG: The ijg has no notion of big endian, therefore always swap the jpeg stream
authormalaterre <malaterre>
Wed, 12 Jan 2005 17:14:40 +0000 (17:14 +0000)
committermalaterre <malaterre>
Wed, 12 Jan 2005 17:14:40 +0000 (17:14 +0000)
src/gdcmJpeg.cxx

index d7579773fdd75064f7a3f18d0de57a48b4cafd6b..45153805c4b247680dea490a0bc4ede45bb4a488 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmJpeg.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/12/12 17:21:08 $
-  Version:   $Revision: 1.29 $
+  Date:      $Date: 2005/01/12 17:14:40 $
+  Version:   $Revision: 1.30 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -542,7 +542,15 @@ bool gdcm_read_JPEG_file ( std::ifstream* fp, void* image_buffer )
 
      //printf( "scanlines: %d\n",cinfo.output_scanline);
       (void) jpeg_read_scanlines(&cinfo, buffer, 1);
-      memcpy( pimage, *buffer,rowsize); 
+// The ijg has no notion of big endian, therefore always swap the jpeg stream
+#if defined(GDCM_WORDS_BIGENDIAN) && (CMAKE_BITS_IN_JSAMPLE != 8)
+      uint16_t *buffer16 = (uint16_t*)*buffer;
+      uint16_t *pimage16 = (uint16_t*)pimage;
+      for(int i=0;i<rowsize/2;i++)
+        pimage16[i] = (buffer16[i] >> 8) | (buffer16[i] << 8 );
+#else
+      memcpy( pimage, *buffer,rowsize);
+#endif //GDCM_WORDS_BIGENDIAN
       pimage+=rowsize;
    }