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