From: malaterre Date: Wed, 12 Jan 2005 17:14:40 +0000 (+0000) Subject: BUG: The ijg has no notion of big endian, therefore always swap the jpeg stream X-Git-Tag: Version1.0.bp~369 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=ef60f9a6d2d07c8479c2e370f9c24e21dbfd1844;p=gdcm.git BUG: The ijg has no notion of big endian, therefore always swap the jpeg stream --- diff --git a/src/gdcmJpeg.cxx b/src/gdcmJpeg.cxx index d7579773..45153805 100644 --- a/src/gdcmJpeg.cxx +++ b/src/gdcmJpeg.cxx @@ -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> 8) | (buffer16[i] << 8 ); +#else + memcpy( pimage, *buffer,rowsize); +#endif //GDCM_WORDS_BIGENDIAN pimage+=rowsize; }