X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=src%2FgdcmJpeg8.cxx;h=fab29603c798ea7a740c3e50b6bc873793430fbd;hb=bd1fa6ade44ea7dffa9d0fed99d5caa15cb7339a;hp=28d0acd17cfabbf2d39082d4363c28a28629fbfd;hpb=782aa96302f4793b605a9edb50a0d9073b2e1663;p=gdcm.git diff --git a/src/gdcmJpeg8.cxx b/src/gdcmJpeg8.cxx index 28d0acd1..fab29603 100644 --- a/src/gdcmJpeg8.cxx +++ b/src/gdcmJpeg8.cxx @@ -1,14 +1,22 @@ -// gdcmJpeg.cxx -//----------------------------------------------------------------------------- -#include +/*========================================================================= + + Program: gdcm + Module: $RCSfile: gdcmJpeg8.cxx,v $ + Language: C++ + Date: $Date: 2004/10/12 04:35:46 $ + Version: $Revision: 1.6 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ #include "gdcmFile.h" -#define BITS_IN_JSAMPLE 8 - -#ifdef GDCM_DEBUG -#define GDCM_jpr_DEBUG 0 -#endif //GDCM_DEBUG - /* DICOM provides a mechanism for supporting the use of JPEG Image Compression through the Encapsulated Format (see PS 3.3 of the DICOM Standard). @@ -77,13 +85,14 @@ of the uncompressed pixel data from which the compressed data is derived */ extern "C" { -//#include "jpeglib.h" #include "src/jpeg/libijg8/jconfig.h" #include "src/jpeg/libijg8/jpeglib.h" #include } +namespace gdcm +{ /******************** JPEG COMPRESSION SAMPLE INTERFACE *******************/ @@ -122,7 +131,7 @@ extern "C" { */ /** - * \ingroup gdcmFile + * \ingroup File * \brief routine for JPEG decompression * @param fp pointer to an already open file descriptor * 8 significant bits per pixel @@ -352,7 +361,6 @@ METHODDEF(void) my_error_exit (j_common_ptr cinfo) { */ /** - * \ingroup gdcmFile * \brief routine for JPEG decompression * @param fp pointer to an already open file descriptor * 8 significant bits per pixel @@ -360,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 gdcm_read_JPEG_file ( FILE* fp, void* image_buffer ) +{ char* pimage; /* This struct contains the JPEG decompression parameters and pointers to @@ -395,7 +404,7 @@ bool gdcmFile::gdcm_read_JPEG_file (FILE* fp, void* image_buffer) { int row_stride;/* physical row width in output buffer */ #ifdef GDCM_JPG_DEBUG - printf("entree dans gdcmFile::gdcm_read_JPEG_file (i.e. 8), depuis gdcmJpeg\n"); + printf("entree dans File::gdcm_read_JPEG_file (i.e. 8), depuis gdcmJpeg\n"); #endif //GDCM_JPG_DEBUG /* In this example we want to open the input file before doing anything else, @@ -415,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. */ @@ -517,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. @@ -527,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?!? } @@ -573,7 +585,7 @@ bool gdcmFile::gdcm_read_JPEG_file (FILE* fp, void* image_buffer) { /* And we're done! */ - return(true); + return true; } @@ -603,3 +615,5 @@ bool gdcmFile::gdcm_read_JPEG_file (FILE* fp, void* image_buffer) { */ //---------------------------------------------------------------------------- + +} // end namespace gdcm