]> Creatis software - gdcm.git/blob - src/gdcmJpeg.cxx
ENH: Finally modify gdcm source to adapt to new jpeg lib, this is not perfect but...
[gdcm.git] / src / gdcmJpeg.cxx
1 // gdcmJpeg.cxx
2 //-----------------------------------------------------------------------------
3 #include <stdio.h>
4 #include "gdcmFile.h"
5
6 #define BITS_IN_JSAMPLE 8
7
8 #ifdef GDCM_DEBUG
9 #define GDCM_jpr_DEBUG 0
10 #endif   //GDCM_DEBUG
11
12 /*
13 DICOM provides a mechanism for supporting the use of JPEG Image Compression 
14 through the Encapsulated Format (see PS 3.3 of the DICOM Standard). 
15 Annex A defines a number of Transfer Syntaxes which reference 
16 the JPEG Standard and provide a number of lossless (bit preserving) 
17 and lossy compression schemes.
18 In order to facilitate interoperability of implementations conforming 
19 to the DICOM Standard which elect to use one or more 
20 of the Transfer Syntaxes for JPEG Image Compression, the following policy is specified:
21
22   Any implementation which conforms to the DICOM Standard and has elected 
23   to support any one of the Transfer Syntaxes for lossless JPEG Image Compression, 
24   shall support the following lossless compression: 
25   The subset (first-order horizontal prediction [Selection Value 1) of JPEG Process 14 
26   (DPCM, non-hierarchical with Huffman coding) (see Annex F of the DICOM Standard).
27
28    Any implementation which conforms to the DICOM Standard and has elected 
29    to support any one of the Transfer Syntaxes for 8-bit lossy JPEG Image Compression, 
30    shall support the JPEG Baseline Compression (coding Process 1).
31
32    Any implementation which conforms to the DICOM Standard and has elected 
33    to support any one of the Transfer Syntaxes for 12-bit lossy JPEG Image Compression, 
34    shall support the JPEG Compression Process 4.
35
36 Note: The DICOM conformance statement shall differentiate between implementations 
37 that can simply receive JPEG encoded images and those that can receive and process 
38 JPEG encoded images (see PS 3.2 of the DICOM Standard).
39
40 The use of the DICOM Encapsulated Format to support JPEG Compressed Pixel Data 
41 implies that the Data Elements which are related to the Native Format Pixel Data encoding
42 (e.g. Bits Allocated, Bits Stored, High Bit, Pixel Representation, Rows, Columns, etc.) 
43 shall contain values which are consistent with the characteristics 
44 of the uncompressed pixel data from which the compressed Data Stream was derived. 
45 The Pixel Data characteristics included in the JPEG Interchange Format 
46 shall be used to decode the compressed data stream.
47
48 Run Length Encoding Compression
49
50 DICOM provides a mechanism for supporting the use of Run Length Encoding (RLE) 
51 Compression which is a byte oriented lossless compression scheme through 
52 the encapsulated Format (see PS 3.3 of this Standard). 
53 Annex G of the DICOM Standard defines RLE Compression and its Transfer Syntax.
54
55 Note: The RLE Compression algorithm described in Annex G 
56 of the DICOM Standard is the compression used in 
57 the TIFF 6.0 specification known as the "PackBits" scheme.
58
59 The use of the DICOM Encapsulated Format to support RLE Compressed Pixel Data 
60 implies that the Data Elements which are related to the Native Format Pixel Data encoding (
61 e.g. Bits Allocated, Bits Stored, High Bit, Pixel Representation, Rows, Columns, etc.) 
62 shall contain values which are consistent with the characteristics 
63 of the uncompressed pixel data from which the compressed data is derived
64 */
65
66 /*
67  * <setjmp.h> is used for the optional error recovery mechanism shown in
68  * the second part of the example.
69  */
70
71 /*
72  * Include file for users of JPEG library.
73  * You will need to have included system headers that define at least
74  * the typedefs FILE and size_t before you can include jpeglib.h.
75  * (stdio.h is sufficient on ANSI-conforming systems.)
76  * You may also wish to include "jerror.h".
77  */
78
79 extern "C" {
80 //#include "jpeglib.h"
81 #include "src/jpeg/libijg8/jconfig.h"
82 #include "src/jpeg/libijg8/jpeglib.h"
83
84 #include <setjmp.h>
85 }
86
87
88 /******************** JPEG COMPRESSION SAMPLE INTERFACE *******************/
89
90 /* This half of the example shows how to feed data into the JPEG compressor.
91  * We present a minimal version that does not worry about refinements such
92  * as error recovery (the JPEG code will just exit() if it gets an error).
93  */
94
95 /*
96  * IMAGE DATA FORMATS:
97  *
98  * The standard input image format is a rectangular array of pixels, with
99  * each pixel having the same number of "component" values (color channels).
100  * Each pixel row is an array of JSAMPLEs (which typically are unsigned chars).
101  * If you are working with color data, then the color values for each pixel
102  * must be adjacent in the row; for example, R,G,B,R,G,B,R,G,B,... for 24-bit
103  * RGB color.
104  *
105  * For this example, we'll assume that this data structure matches the way
106  * our application has stored the image in memory, so we can just pass a
107  * pointer to our image buffer.  In particular, let's say that the image is
108  * RGB color and is described by:
109  */
110
111 // FIXME : JPR
112
113 //extern JSAMPLE * image_buffer; /* Points to large array of R,G,B-order data */
114 //extern int image_height;       /* Number of rows in image */
115 //extern int image_width;        /* Number of columns in image */
116
117
118
119 /*
120  * Sample routine for JPEG compression.  We assume that the target file name
121  * and a compression quality factor are passed in.
122  */
123
124  /**
125  * \ingroup gdcmFile
126  * \brief   routine for JPEG decompression 
127  * @param fp pointer to an already open file descriptor 
128  *                      8 significant bits per pixel
129  * @param image_buffer Points to array (of R,G,B-order) data to compress
130  * @param quality compression quality
131  * @param image_height Number of rows in image 
132  * @param image_width Number of columns in image
133  * @return 1 on success, 0 on error
134  */
135  
136 bool gdcm_write_JPEG_file (FILE* fp, void*  im_buf, 
137                            int image_width, int image_height, int quality)
138 {
139
140    JSAMPLE* image_buffer = (JSAMPLE*) im_buf;
141
142   /* This struct contains the JPEG compression parameters and pointers to
143    * working space (which is allocated as needed by the JPEG library).
144    * It is possible to have several such structures, representing multiple
145    * compression/decompression processes, in existence at once.  We refer
146    * to any one struct (and its associated working data) as a "JPEG object".
147    */
148   struct jpeg_compress_struct cinfo;
149   /* This struct represents a JPEG error handler.  It is declared separately
150    * because applications often want to supply a specialized error handler
151    * (see the second half of this file for an example).  But here we just
152    * take the easy way out and use the standard error handler, which will
153    * print a message on stderr and call exit() if compression fails.
154    * Note that this struct must live as long as the main JPEG parameter
155    * struct, to avoid dangling-pointer problems.
156    */
157   struct jpeg_error_mgr jerr;
158   /* More stuff */
159   //FILE*  outfile;    /* target FILE* /
160   JSAMPROW row_pointer[1];   /* pointer to JSAMPLE row[s] */
161   int row_stride;            /* physical row width in image buffer */
162
163   /* Step 1: allocate and initialize JPEG compression object */
164
165   /* We have to set up the error handler first, in case the initialization
166    * step fails.  (Unlikely, but it could happen if you are out of memory.)
167    * This routine fills in the contents of struct jerr, and returns jerr's
168    * address which we place into the link field in cinfo.
169    */
170   cinfo.err = jpeg_std_error(&jerr);
171   /* Now we can initialize the JPEG compression object. */
172   jpeg_create_compress(&cinfo);
173
174   /* Step 2: specify data destination (eg, a file) */
175   /* Note: steps 2 and 3 can be done in either order. */
176
177   /* Here we use the library-supplied code to send compressed data to a
178    * stdio stream.  You can also write your own code to do something else.
179    * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that
180    * requires it in order to write binary files.
181    */
182  // if ((outfile = fopen(filename, "wb")) == NULL) {
183  //   fprintf(stderr, "can't open %s\n", filename);
184  //   exit(1);
185  //
186  // }
187   jpeg_stdio_dest(&cinfo, fp);
188
189   /* Step 3: set parameters for compression */
190
191   /* First we supply a description of the input image.
192    * Four fields of the cinfo struct must be filled in:
193    */
194   cinfo.image_width = image_width;/* image width and height, in pixels */
195   cinfo.image_height = image_height;
196   cinfo.input_components = 3;     /* # of color components per pixel */
197   cinfo.in_color_space = JCS_RGB; /* colorspace of input image */
198   /* Now use the library's routine to set default compression parameters.
199    * (You must set at least cinfo.in_color_space before calling this,
200    * since the defaults depend on the source color space.)
201    */
202   jpeg_set_defaults(&cinfo);
203   /* Now you can set any non-default parameters you wish to.
204    * Here we just illustrate the use of quality (quantization table) scaling:
205    */
206   jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */);
207
208   /* Step 4: Start compressor */
209
210   /* TRUE ensures that we will write a complete interchange-JPEG file.
211    * Pass TRUE unless you are very sure of what you're doing.
212    */
213   jpeg_start_compress(&cinfo, TRUE);
214
215   /* Step 5: while (scan lines remain to be written) */
216   /*           jpeg_write_scanlines(...); */
217
218   /* Here we use the library's state variable cinfo.next_scanline as the
219    * loop counter, so that we don't have to keep track ourselves.
220    * To keep things simple, we pass one scanline per call; you can pass
221    * more if you wish, though.
222    */
223   row_stride = image_width * 3;/* JSAMPLEs per row in image_buffer */
224
225   while (cinfo.next_scanline < cinfo.image_height) {
226     /* jpeg_write_scanlines expects an array of pointers to scanlines.
227      * Here the array is only one element long, but you could pass
228      * more than one scanline at a time if that's more convenient.
229      */
230     row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride];
231
232     (void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
233   }
234
235   /* Step 6: Finish compression */
236
237   jpeg_finish_compress(&cinfo);
238   
239   /* After finish_compress, we can close the output file. */
240   
241  // fclose(fp); --> the caller will close (multiframe treatement)
242
243   /* Step 7: release JPEG compression object */
244
245   /* This is an important step since it will release a good deal of memory. */
246   jpeg_destroy_compress(&cinfo);
247
248   /* And we're done! */
249
250   return true; //???
251 }
252
253
254
255 /*
256  * SOME FINE POINTS:
257  *
258  * In the above loop, we ignored the return value of jpeg_write_scanlines,
259  * which is the number of scanlines actually written.  We could get away
260  * with this because we were only relying on the value of cinfo.next_scanline,
261  * which will be incremented correctly.  If you maintain additional loop
262  * variables then you should be careful to increment them properly.
263  * Actually, for output to a stdio stream you needn't worry, because
264  * then jpeg_write_scanlines will write all the lines passed (or else exit
265  * with a fatal error).  Partial writes can only occur if you use a data
266  * destination module that can demand suspension of the compressor.
267  * (If you don't know what that's for, you don't need it.)
268  *
269  * If the compressor requires full-image buffers (for entropy-coding
270  * optimization or a multi-scan JPEG file), it will create temporary
271  * files for anything that doesn't fit within the maximum-memory setting.
272  * (Note that temp files are NOT needed if you use the default parameters.)
273  * On some systems you may need to set up a signal handler to ensure that
274  * temporary files are deleted if the program is interrupted.  See libjpeg.doc.
275  *
276  * Scanlines MUST be supplied in top-to-bottom order if you want your JPEG
277  * files to be compatible with everyone else's.  If you cannot readily read
278  * your data in that order, you'll need an intermediate array to hold the
279  * image.  See rdtarga.c or rdbmp.c for examples of handling bottom-to-top
280  * source data using the JPEG code's internal virtual-array mechanisms.
281  */
282
283
284
285 /******************** JPEG DECOMPRESSION SAMPLE INTERFACE *******************/
286
287 /* This half of the example shows how to read data from the JPEG decompressor.
288  * It's a bit more refined than the above, in that we show:
289  *   (a) how to modify the JPEG library's standard error-reporting behavior;
290  *   (b) how to allocate workspace using the library's memory manager.
291  *
292  * Just to make this example a little different from the first one, we'll
293  * assume that we do not intend to put the whole image into an in-memory
294  * buffer, but to send it line-by-line someplace else.  We need a one-
295  * scanline-high JSAMPLE array as a work buffer, and we will let the JPEG
296  * memory manager allocate it for us.  This approach is actually quite useful
297  * because we don't need to remember to deallocate the buffer separately: it
298  * will go away automatically when the JPEG object is cleaned up.
299  */
300
301 /*
302  * ERROR HANDLING:
303  *
304  * The JPEG library's standard error handler (jerror.c) is divided into
305  * several "methods" which you can override individually.  This lets you
306  * adjust the behavior without duplicating a lot of code, which you might
307  * have to update with each future release.
308  *
309  * Our example here shows how to override the "error_exit" method so that
310  * control is returned to the library's caller when a fatal error occurs,
311  * rather than calling exit() as the standard error_exit method does.
312  *
313  * We use C's setjmp/longjmp facility to return control.  This means that the
314  * routine which calls the JPEG library must first execute a setjmp() call to
315  * establish the return point.  We want the replacement error_exit to do a
316  * longjmp().  But we need to make the setjmp buffer accessible to the
317  * error_exit routine.  To do this, we make a private extension of the
318  * standard JPEG error handler object.  (If we were using C++, we'd say we
319  * were making a subclass of the regular error handler.)
320  *
321  * Here's the extended error handler struct:
322  */
323
324 //-----------------------------------------------------------------------------
325 struct my_error_mgr {
326    struct jpeg_error_mgr pub; /* "public" fields */
327    jmp_buf setjmp_buffer;     /* for return to caller */
328 };
329
330 //-----------------------------------------------------------------------------
331 typedef struct my_error_mgr* my_error_ptr;
332
333 /*
334  * Here's the routine that will replace the standard error_exit method:
335  */
336 METHODDEF(void) my_error_exit (j_common_ptr cinfo) {
337    /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
338    my_error_ptr myerr = (my_error_ptr) cinfo->err;
339
340    /* Always display the message. */
341    /* We could postpone this until after returning, if we chose. */
342    (*cinfo->err->output_message) (cinfo);
343
344    /* Return control to the setjmp point */
345    longjmp(myerr->setjmp_buffer, 1);
346 }
347
348 //-----------------------------------------------------------------------------
349 /*
350  * Sample routine for JPEG decompression.  We assume that the source file name
351  * is passed in.  We want to return 1 on success, 0 on error.
352  */
353  
354  /**
355  * \ingroup gdcmFile
356  * \brief   routine for JPEG decompression 
357  * @param fp pointer to an already open file descriptor 
358  *                      8 significant bits per pixel
359  * @param image_buffer to receive uncompressed pixels
360  * @return 1 on success, 0 on error
361  */
362  
363 bool gdcmFile::gdcm_read_JPEG_file (FILE* fp, void* image_buffer) {
364    char* pimage;
365
366    /* This struct contains the JPEG decompression parameters and pointers to
367     * working space (which is allocated as needed by the JPEG library).
368     */
369    struct jpeg_decompress_struct cinfo;
370
371    /* -------------- inside, we found :
372     * JDIMENSION image_width;       // input image width 
373     * JDIMENSION image_height;      // input image height 
374     * int input_components;         // nb of color components in input image 
375     * J_COLOR_SPACE in_color_space; // colorspace of input image 
376     * double input_gamma;           // image gamma of input image 
377     * -------------- */
378
379    /* We use our private extension JPEG error handler.
380     * Note that this struct must live as long as the main JPEG parameter
381     * struct, to avoid dangling-pointer problems.
382     */
383    struct my_error_mgr jerr;
384    /* More stuff */
385
386    JSAMPARRAY buffer;/* Output row buffer */
387   
388    // rappel :
389    // ------
390    // typedef unsigned char JSAMPLE;
391    // typedef JSAMPLE FAR *JSAMPROW;/* ptr to one image row of pixel samples. */
392    // typedef JSAMPROW *JSAMPARRAY;/* ptr to some rows (a 2-D sample array) */
393    // typedef JSAMPARRAY *JSAMPIMAGE;/* a 3-D sample array: top index is color */
394
395    int row_stride;/* physical row width in output buffer */
396   
397 #ifdef GDCM_JPG_DEBUG
398    printf("entree dans gdcmFile::gdcm_read_JPEG_file (i.e. 8), depuis gdcmJpeg\n");
399 #endif //GDCM_JPG_DEBUG
400
401    /* In this example we want to open the input file before doing anything else,
402     * so that the setjmp() error recovery below can assume the file is open.
403     * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that
404     * requires it in order to read binary files.
405     */
406     
407   /* Step 1: allocate and initialize JPEG decompression object */  
408 #ifdef GDCM_JPG_DEBUG
409   printf("Entree Step 1\n");
410 #endif //GDCM_JPG_DEBUG
411   
412   /* We set up the normal JPEG error routines, then override error_exit. */
413   
414   cinfo.err = jpeg_std_error(&jerr.pub);
415   jerr.pub.error_exit = my_error_exit;
416   
417   /* Establish the setjmp return context for my_error_exit to use. */  
418   if (setjmp(jerr.setjmp_buffer)) {
419     /* If we get here, the JPEG code has signaled an error.
420      * We need to clean up the JPEG object, close the input file, and return.
421      */
422     jpeg_destroy_decompress(&cinfo);
423     return 0;
424   }
425   /* Now we can initialize the JPEG decompression object. */
426   jpeg_create_decompress(&cinfo);
427
428    /* Step 2: specify data source (eg, a file) */
429 #ifdef GDCM_JPG_DEBUG
430   printf("Entree Step 2\n");
431 #endif //GDCM_JPG_DEBUG
432
433    jpeg_stdio_src(&cinfo, fp);
434
435    /* Step 3: read file parameters with jpeg_read_header() */
436 #ifdef GDCM_JPG_DEBUG
437   printf("Entree Step 3\n");
438 #endif //GDCM_JPG_DEBUG
439
440    (void) jpeg_read_header(&cinfo, TRUE);
441    
442    /* We can ignore the return value from jpeg_read_header since
443     *   (a) suspension is not possible with the stdio data source, and
444     *   (b) we passed TRUE to reject a tables-only JPEG file as an error.
445     * See libjpeg.doc for more info.
446     */
447
448 #ifdef GDCM_JPG_DEBUG
449       printf("--------------Header contents :----------------\n");
450       printf("image_width %d image_height %d\n", 
451               cinfo.image_width , cinfo.image_height);
452       printf("bits of precision in image data  %d \n", 
453               cinfo.output_components);
454       printf("nb of color components returned  %d \n", 
455               cinfo.data_precision);
456 #endif //GDCM_JPG_DEBUG
457
458
459    /*
460     * JDIMENSION image_width;       // input image width 
461     * JDIMENSION image_height;      // input image height 
462     * int output_components;        // # of color components returned 
463     * J_COLOR_SPACE in_color_space; // colorspace of input image 
464     * double input_gamma;           // image gamma of input image
465     * int data_precision;           // bits of precision in image data 
466     */
467
468    /* Step 4: set parameters for decompression */
469 #ifdef GDCM_JPG_DEBUG
470   printf("Entree Step 4\n");
471 #endif //GDCM_JPG_DEBUG
472    /* In this example, we don't need to change any of the defaults set by
473     * jpeg_read_header(), so we do nothing here.
474     */
475
476    /* Step 5: Start decompressor */
477 #ifdef GDCM_JPG_DEBUG
478    printf("Entree Step 5\n");
479 #endif //GDCM_JPG_DEBUG
480
481    (void) jpeg_start_decompress(&cinfo);
482    /* We can ignore the return value since suspension is not possible
483     * with the stdio data source.
484     */
485
486    /* We may need to do some setup of our own at this point before reading
487     * the data.  After jpeg_start_decompress() we have the correct scaled
488     * output image dimensions available, as well as the output colormap
489     * if we asked for color quantization.
490     * In this example, we need to make an output work buffer of the right size.
491     */ 
492
493    /* JSAMPLEs per row in output buffer */
494    row_stride = cinfo.output_width * cinfo.output_components;
495   
496 #ifdef GDCM_JPG_DEBUG
497   printf ("cinfo.output_width %d cinfo.output_components %d  row_stride %d\n",
498                       cinfo.output_width, cinfo.output_components,row_stride);
499 #endif //GDCM_JPG_DEBUG
500
501    /* Make a one-row-high sample array that will go away when done with image */
502    buffer = (*cinfo.mem->alloc_sarray)
503             ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
504
505    /* Step 6: while (scan lines remain to be read) */
506 #ifdef GDCM_JPG_DEBUG
507     printf("Entree Step 6\n"); 
508 #endif //GDCM_JPG_DEBUG
509    /*           jpeg_read_scanlines(...); */
510
511    /* Here we use the library's state variable cinfo.output_scanline as the
512     * loop counter, so that we don't have to keep track ourselves.
513     */
514 #ifdef GDCM_JPG_DEBUG
515       printf ("cinfo.output_height %d  cinfo.output_width %d\n",
516                cinfo.output_height,cinfo.output_width);
517 #endif //GDCM_JPG_DEBUG
518    pimage=(char *)image_buffer;
519   
520    while (cinfo.output_scanline < cinfo.output_height) {
521       /* jpeg_read_scanlines expects an array of pointers to scanlines.
522        * Here the array is only one element long, but you could ask for
523        * more than one scanline at a time if that's more convenient.
524        */
525      
526      // l'image est deja allouée (et passée en param)
527      // on ecrit directement les pixels
528      // (on DEVRAIT pouvoir)
529     
530     //(void) jpeg_read_scanlines(&cinfo, pimage, 1);
531     
532      (void) jpeg_read_scanlines(&cinfo, buffer, 1);
533       
534      if ( BITS_IN_JSAMPLE == 8) {
535          memcpy( pimage, buffer[0],row_stride); 
536          pimage+=row_stride;
537      } else {
538          memcpy( pimage, buffer[0],row_stride*2 ); // FIXME : *2  car 16 bits?!?
539          pimage+=row_stride*2;                     // FIXME : *2 car 16 bits?!?     
540      }
541   }
542  
543   /* Step 7: Finish decompression */
544 #ifdef GDCM_JPG_DEBUG
545    printf("Entree Step 7\n");
546 #endif //GDCM_JPG_DEBUG
547
548    (void) jpeg_finish_decompress(&cinfo);
549    
550    /* We can ignore the return value since suspension is not possible
551     * with the stdio data source.
552     */
553
554    /* Step 8: Release JPEG decompression object */
555
556 #ifdef GDCM_JPG_DEBUG
557   printf("Entree Step 8\n");
558 #endif //GDCM_JPG_DEBUG
559
560    /* This is an important step since it will release a good deal of memory. */
561
562    jpeg_destroy_decompress(&cinfo);
563
564    /* After finish_decompress, we can close the input file.
565     * Here we postpone it until after no more JPEG errors are possible,
566     * so as to simplify the setjmp error logic above.  (Actually, I don't
567     * think that jpeg_destroy can do an error exit, but why assume anything...)
568     */
569
570    /* At this point you may want to check to see whether any corrupt-data
571     * warnings occurred (test whether jerr.pub.num_warnings is nonzero).
572     */
573
574    /* And we're done! */
575
576    return(true);
577 }
578
579
580 /*
581  * SOME FINE POINTS:
582  *
583  * In the above code, we ignored the return value of jpeg_read_scanlines,
584  * which is the number of scanlines actually read.  We could get away with
585  * this because we asked for only one line at a time and we weren't using
586  * a suspending data source.  See libjpeg.doc for more info.
587  *
588  * We cheated a bit by calling alloc_sarray() after jpeg_start_decompress();
589  * we should have done it beforehand to ensure that the space would be
590  * counted against the JPEG max_memory setting.  In some systems the above
591  * code would risk an out-of-memory error.  However, in general we don't
592  * know the output image dimensions before jpeg_start_decompress(), unless we
593  * call jpeg_calc_output_dimensions().  See libjpeg.doc for more about this.
594  *
595  * Scanlines are returned in the same order as they appear in the JPEG file,
596  * which is standardly top-to-bottom.  If you must emit data bottom-to-top,
597  * you can use one of the virtual arrays provided by the JPEG memory manager
598  * to invert the data.  See wrbmp.c for an example.
599  *
600  * As with compression, some operating modes may require temporary files.
601  * On some systems you may need to set up a signal handler to ensure that
602  * temporary files are deleted if the program is interrupted.  See libjpeg.doc.
603  */
604  
605 //----------------------------------------------------------------------------