-/******************** JPEG COMPRESSION SAMPLE INTERFACE *******************/
-
-//
-// TODO
-//
-
-bool gdcm_write_JPEG_file12 (FILE* fp, void* im_buff,
- int image_width, int image_heigh, int quality)
-{
- (void)fp;
- (void)im_buff;
- (void)image_width;
- (void)image_heigh;
- (void)quality;
-
- return true; //???
-}
-
-/******************** JPEG DECOMPRESSION SAMPLE INTERFACE *******************/
-
-/* This half of the example shows how to read data from the JPEG decompressor.
- * It's a bit more refined than the above, in that we show:
- * (a) how to modify the JPEG library's standard error-reporting behavior;
- * (b) how to allocate workspace using the library's memory manager.
- *
- * Just to make this example a little different from the first one, we'll
- * assume that we do not intend to put the whole image into an in-memory
- * buffer, but to send it line-by-line someplace else. We need a one-
- * scanline-high JSAMPLE array as a work buffer, and we will let the JPEG
- * memory manager allocate it for us. This approach is actually quite useful
- * because we don't need to remember to deallocate the buffer separately: it
- * will go away automatically when the JPEG object is cleaned up.
- */
-
-/*
- * ERROR HANDLING:
- *
- * The JPEG library's standard error handler (jerror.c) is divided into
- * several "methods" which you can override individually. This lets you
- * adjust the behavior without duplicating a lot of code, which you might
- * have to update with each future release.
- *
- * Our example here shows how to override the "error_exit" method so that
- * control is returned to the library's caller when a fatal error occurs,
- * rather than calling exit() as the standard error_exit method does.
- *
- * We use C's setjmp/longjmp facility to return control. This means that the
- * routine which calls the JPEG library must first execute a setjmp() call to
- * establish the return point. We want the replacement error_exit to do a
- * longjmp(). But we need to make the setjmp buffer accessible to the
- * error_exit routine. To do this, we make a private extension of the
- * standard JPEG error handler object. (If we were using C++, we'd say we
- * were making a subclass of the regular error handler.)
- *
- * Here's the extended error handler struct:
- */
-
-//-----------------------------------------------------------------------------
-struct my_error_mgr {
- struct jpeg_error_mgr pub; /* "public" fields */
- jmp_buf setjmp_buffer; /* for return to caller */
-};
-
-//-----------------------------------------------------------------------------
-typedef struct my_error_mgr * my_error_ptr;
-
-/*
- * Here's the routine that will replace the standard error_exit method:
- */
-METHODDEF(void) my_error_exit (j_common_ptr cinfo)
-{
- /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
- my_error_ptr myerr = (my_error_ptr) cinfo->err;
-
- /* Always display the message. */
- /* We could postpone this until after returning, if we chose. */
- (*cinfo->err->output_message) (cinfo);
-
- /* Return control to the setjmp point */
- longjmp(myerr->setjmp_buffer, 1);
-}
-
-
-//-----------------------------------------------------------------------------
-/*
- * Sample routine for JPEG decompression. We assume that the source file name
- * is passed in. We want to return 1 on success, 0 on error.
- */
-
- /**
- * \ingroup gdcmFile
- * \brief routine for JPEG decompression
- * @param fp pointer to an already open file descriptor
- * 12 significant bits per pixel
- * @param image_buffer to receive uncompressed pixels
- * @return 1 on success, 0 on error
- */
-
-bool gdcm_read_JPEG_file12 ( FILE* fp,void* image_buffer )
-{
- char *pimage;
-
- /* This struct contains the JPEG decompression parameters and pointers to
- * working space (which is allocated as needed by the JPEG library).
- */
- struct jpeg_decompress_struct cinfo;
-
- /* -------------- inside, we found :
- * JDIMENSION image_width; // input image width
- * JDIMENSION image_height; // input image height
- * int input_components; // nb of color components in input image
- * J_COLOR_SPACE in_color_space;// colorspace of input image
- * double input_gamma; // image gamma of input image
- * -------------- */
-
- /* We use our private extension JPEG error handler.
- * Note that this struct must live as long as the main JPEG parameter
- * struct, to avoid dangling-pointer problems.
- */
- struct my_error_mgr jerr;
- /* More stuff */
-
- JSAMPARRAY buffer;/* Output row buffer */
-
- // rappel :
- // ------
- // typedef unsigned char JSAMPLE;
- // typedef JSAMPLE FAR *JSAMPROW;/* ptr to one image row of pixel samples. */
- // typedef JSAMPROW *JSAMPARRAY;/* ptr to some rows (a 2-D sample array) */
- // typedef JSAMPARRAY *JSAMPIMAGE;/* a 3-D sample array: top index is color */
-
- int row_stride;/* physical row width in output buffer */
-#ifdef GDCM_JPG_DEBUG
- printf("entree dans gdcmFile::gdcm_read_JPEG_file12, depuis gdcmJpeg\n");
-#endif //GDCM_JPG_DEBUG
-
- /* In this example we want to open the input file before doing anything else,
- * so that the setjmp() error recovery below can assume the file is open.
- * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that
- * requires it in order to read binary files.
- */
-
- /* Step 1: allocate and initialize JPEG decompression object */
-#ifdef GDCM_JPG_DEBUG
- printf("Entree Step 1\n");
-#endif //GDCM_JPG_DEBUG
-
- /* We set up the normal JPEG error routines, then override error_exit. */
-
- cinfo.err = jpeg_std_error(&jerr.pub);
- jerr.pub.error_exit = my_error_exit;
-
- /* Establish the setjmp return context for my_error_exit to use. */
- 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.
- */
- jpeg_destroy_decompress(&cinfo);
- return(false);
- }
-
- /* Now we can initialize the JPEG decompression object. */
- jpeg_create_decompress(&cinfo);