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
*/
/**
- * \ingroup File
* \brief routine for JPEG decompression
* @param fp pointer to an already open file descriptor
* 8 significant bits per pixel
//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;
}
//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<rowsize/2;i++)
+ pimage16[i] = (buffer16[i] >> 8) | (buffer16[i] << 8 );
+#else
+ memcpy( pimage, *buffer,rowsize);
+#endif //GDCM_WORDS_BIGENDIAN
pimage+=rowsize;
}