X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmJpeg.cxx;h=28f58b3f7e0d9f27f0db32c690f265374d41f7e7;hb=038a3b7f67769dc20b4c46f3c9dcad7cc63d1161;hp=d7579773fdd75064f7a3f18d0de57a48b4cafd6b;hpb=dd4e6402f3542ddd5e1cc14a29ca3f84a9f063b6;p=gdcm.git diff --git a/src/gdcmJpeg.cxx b/src/gdcmJpeg.cxx index d7579773..28f58b3f 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/18 08:01:41 $ + Version: $Revision: 1.32 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -127,7 +127,6 @@ namespace gdcm */ /** - * \ingroup File * \brief routine for JPEG decompression * @param fp pointer to an already open file descriptor * 8 significant bits per pixel @@ -542,7 +541,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; } @@ -814,7 +821,14 @@ bool gdcm_read_JPEG_memory ( const JOCTET* input_buffer, const size_t buflen, //printf( "scanlines: %d\n",cinfo.output_scanline); (void) jpeg_read_scanlines(&cinfo, buffer, 1); - memcpy( pimage, *buffer,rowsize); +#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; }