kusano 7d535a
/*
kusano 7d535a
 * example.c
kusano 7d535a
 *
kusano 7d535a
 * This file illustrates how to use the IJG code as a subroutine library
kusano 7d535a
 * to read or write JPEG image files.  You should look at this code in
kusano 7d535a
 * conjunction with the documentation file libjpeg.txt.
kusano 7d535a
 *
kusano 7d535a
 * This code will not do anything useful as-is, but it may be helpful as a
kusano 7d535a
 * skeleton for constructing routines that call the JPEG library.  
kusano 7d535a
 *
kusano 7d535a
 * We present these routines in the same coding style used in the JPEG code
kusano 7d535a
 * (ANSI function definitions, etc); but you are of course free to code your
kusano 7d535a
 * routines in a different style if you prefer.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#include <stdio.h></stdio.h>
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * Include file for users of JPEG library.
kusano 7d535a
 * You will need to have included system headers that define at least
kusano 7d535a
 * the typedefs FILE and size_t before you can include jpeglib.h.
kusano 7d535a
 * (stdio.h is sufficient on ANSI-conforming systems.)
kusano 7d535a
 * You may also wish to include "jerror.h".
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#include "jpeglib.h"
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * <setjmp.h> is used for the optional error recovery mechanism shown in</setjmp.h>
kusano 7d535a
 * the second part of the example.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#include <setjmp.h></setjmp.h>
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
/******************** JPEG COMPRESSION SAMPLE INTERFACE *******************/
kusano 7d535a
kusano 7d535a
/* This half of the example shows how to feed data into the JPEG compressor.
kusano 7d535a
 * We present a minimal version that does not worry about refinements such
kusano 7d535a
 * as error recovery (the JPEG code will just exit() if it gets an error).
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * IMAGE DATA FORMATS:
kusano 7d535a
 *
kusano 7d535a
 * The standard input image format is a rectangular array of pixels, with
kusano 7d535a
 * each pixel having the same number of "component" values (color channels).
kusano 7d535a
 * Each pixel row is an array of JSAMPLEs (which typically are unsigned chars).
kusano 7d535a
 * If you are working with color data, then the color values for each pixel
kusano 7d535a
 * must be adjacent in the row; for example, R,G,B,R,G,B,R,G,B,... for 24-bit
kusano 7d535a
 * RGB color.
kusano 7d535a
 *
kusano 7d535a
 * For this example, we'll assume that this data structure matches the way
kusano 7d535a
 * our application has stored the image in memory, so we can just pass a
kusano 7d535a
 * pointer to our image buffer.  In particular, let's say that the image is
kusano 7d535a
 * RGB color and is described by:
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
extern JSAMPLE * image_buffer;	/* Points to large array of R,G,B-order data */
kusano 7d535a
extern int image_height;	/* Number of rows in image */
kusano 7d535a
extern int image_width;		/* Number of columns in image */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * Sample routine for JPEG compression.  We assume that the target file name
kusano 7d535a
 * and a compression quality factor are passed in.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
GLOBAL(void)
kusano 7d535a
write_JPEG_file (char * filename, int quality)
kusano 7d535a
{
kusano 7d535a
  /* This struct contains the JPEG compression parameters and pointers to
kusano 7d535a
   * working space (which is allocated as needed by the JPEG library).
kusano 7d535a
   * It is possible to have several such structures, representing multiple
kusano 7d535a
   * compression/decompression processes, in existence at once.  We refer
kusano 7d535a
   * to any one struct (and its associated working data) as a "JPEG object".
kusano 7d535a
   */
kusano 7d535a
  struct jpeg_compress_struct cinfo;
kusano 7d535a
  /* This struct represents a JPEG error handler.  It is declared separately
kusano 7d535a
   * because applications often want to supply a specialized error handler
kusano 7d535a
   * (see the second half of this file for an example).  But here we just
kusano 7d535a
   * take the easy way out and use the standard error handler, which will
kusano 7d535a
   * print a message on stderr and call exit() if compression fails.
kusano 7d535a
   * Note that this struct must live as long as the main JPEG parameter
kusano 7d535a
   * struct, to avoid dangling-pointer problems.
kusano 7d535a
   */
kusano 7d535a
  struct jpeg_error_mgr jerr;
kusano 7d535a
  /* More stuff */
kusano 7d535a
  FILE * outfile;		/* target file */
kusano 7d535a
  JSAMPROW row_pointer[1];	/* pointer to JSAMPLE row[s] */
kusano 7d535a
  int row_stride;		/* physical row width in image buffer */
kusano 7d535a
kusano 7d535a
  /* Step 1: allocate and initialize JPEG compression object */
kusano 7d535a
kusano 7d535a
  /* We have to set up the error handler first, in case the initialization
kusano 7d535a
   * step fails.  (Unlikely, but it could happen if you are out of memory.)
kusano 7d535a
   * This routine fills in the contents of struct jerr, and returns jerr's
kusano 7d535a
   * address which we place into the link field in cinfo.
kusano 7d535a
   */
kusano 7d535a
  cinfo.err = jpeg_std_error(&jerr);
kusano 7d535a
  /* Now we can initialize the JPEG compression object. */
kusano 7d535a
  jpeg_create_compress(&cinfo);
kusano 7d535a
kusano 7d535a
  /* Step 2: specify data destination (eg, a file) */
kusano 7d535a
  /* Note: steps 2 and 3 can be done in either order. */
kusano 7d535a
kusano 7d535a
  /* Here we use the library-supplied code to send compressed data to a
kusano 7d535a
   * stdio stream.  You can also write your own code to do something else.
kusano 7d535a
   * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that
kusano 7d535a
   * requires it in order to write binary files.
kusano 7d535a
   */
kusano 7d535a
  if ((outfile = fopen(filename, "wb")) == NULL) {
kusano 7d535a
    fprintf(stderr, "can't open %s\n", filename);
kusano 7d535a
    exit(1);
kusano 7d535a
  }
kusano 7d535a
  jpeg_stdio_dest(&cinfo, outfile);
kusano 7d535a
kusano 7d535a
  /* Step 3: set parameters for compression */
kusano 7d535a
kusano 7d535a
  /* First we supply a description of the input image.
kusano 7d535a
   * Four fields of the cinfo struct must be filled in:
kusano 7d535a
   */
kusano 7d535a
  cinfo.image_width = image_width; 	/* image width and height, in pixels */
kusano 7d535a
  cinfo.image_height = image_height;
kusano 7d535a
  cinfo.input_components = 3;		/* # of color components per pixel */
kusano 7d535a
  cinfo.in_color_space = JCS_RGB; 	/* colorspace of input image */
kusano 7d535a
  /* Now use the library's routine to set default compression parameters.
kusano 7d535a
   * (You must set at least cinfo.in_color_space before calling this,
kusano 7d535a
   * since the defaults depend on the source color space.)
kusano 7d535a
   */
kusano 7d535a
  jpeg_set_defaults(&cinfo);
kusano 7d535a
  /* Now you can set any non-default parameters you wish to.
kusano 7d535a
   * Here we just illustrate the use of quality (quantization table) scaling:
kusano 7d535a
   */
kusano 7d535a
  jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */);
kusano 7d535a
kusano 7d535a
  /* Step 4: Start compressor */
kusano 7d535a
kusano 7d535a
  /* TRUE ensures that we will write a complete interchange-JPEG file.
kusano 7d535a
   * Pass TRUE unless you are very sure of what you're doing.
kusano 7d535a
   */
kusano 7d535a
  jpeg_start_compress(&cinfo, TRUE);
kusano 7d535a
kusano 7d535a
  /* Step 5: while (scan lines remain to be written) */
kusano 7d535a
  /*           jpeg_write_scanlines(...); */
kusano 7d535a
kusano 7d535a
  /* Here we use the library's state variable cinfo.next_scanline as the
kusano 7d535a
   * loop counter, so that we don't have to keep track ourselves.
kusano 7d535a
   * To keep things simple, we pass one scanline per call; you can pass
kusano 7d535a
   * more if you wish, though.
kusano 7d535a
   */
kusano 7d535a
  row_stride = image_width * 3;	/* JSAMPLEs per row in image_buffer */
kusano 7d535a
kusano 7d535a
  while (cinfo.next_scanline < cinfo.image_height) {
kusano 7d535a
    /* jpeg_write_scanlines expects an array of pointers to scanlines.
kusano 7d535a
     * Here the array is only one element long, but you could pass
kusano 7d535a
     * more than one scanline at a time if that's more convenient.
kusano 7d535a
     */
kusano 7d535a
    row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride];
kusano 7d535a
    (void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
kusano 7d535a
  }
kusano 7d535a
kusano 7d535a
  /* Step 6: Finish compression */
kusano 7d535a
kusano 7d535a
  jpeg_finish_compress(&cinfo);
kusano 7d535a
  /* After finish_compress, we can close the output file. */
kusano 7d535a
  fclose(outfile);
kusano 7d535a
kusano 7d535a
  /* Step 7: release JPEG compression object */
kusano 7d535a
kusano 7d535a
  /* This is an important step since it will release a good deal of memory. */
kusano 7d535a
  jpeg_destroy_compress(&cinfo);
kusano 7d535a
kusano 7d535a
  /* And we're done! */
kusano 7d535a
}
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * SOME FINE POINTS:
kusano 7d535a
 *
kusano 7d535a
 * In the above loop, we ignored the return value of jpeg_write_scanlines,
kusano 7d535a
 * which is the number of scanlines actually written.  We could get away
kusano 7d535a
 * with this because we were only relying on the value of cinfo.next_scanline,
kusano 7d535a
 * which will be incremented correctly.  If you maintain additional loop
kusano 7d535a
 * variables then you should be careful to increment them properly.
kusano 7d535a
 * Actually, for output to a stdio stream you needn't worry, because
kusano 7d535a
 * then jpeg_write_scanlines will write all the lines passed (or else exit
kusano 7d535a
 * with a fatal error).  Partial writes can only occur if you use a data
kusano 7d535a
 * destination module that can demand suspension of the compressor.
kusano 7d535a
 * (If you don't know what that's for, you don't need it.)
kusano 7d535a
 *
kusano 7d535a
 * If the compressor requires full-image buffers (for entropy-coding
kusano 7d535a
 * optimization or a multi-scan JPEG file), it will create temporary
kusano 7d535a
 * files for anything that doesn't fit within the maximum-memory setting.
kusano 7d535a
 * (Note that temp files are NOT needed if you use the default parameters.)
kusano 7d535a
 * On some systems you may need to set up a signal handler to ensure that
kusano 7d535a
 * temporary files are deleted if the program is interrupted.  See libjpeg.txt.
kusano 7d535a
 *
kusano 7d535a
 * Scanlines MUST be supplied in top-to-bottom order if you want your JPEG
kusano 7d535a
 * files to be compatible with everyone else's.  If you cannot readily read
kusano 7d535a
 * your data in that order, you'll need an intermediate array to hold the
kusano 7d535a
 * image.  See rdtarga.c or rdbmp.c for examples of handling bottom-to-top
kusano 7d535a
 * source data using the JPEG code's internal virtual-array mechanisms.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
/******************** JPEG DECOMPRESSION SAMPLE INTERFACE *******************/
kusano 7d535a
kusano 7d535a
/* This half of the example shows how to read data from the JPEG decompressor.
kusano 7d535a
 * It's a bit more refined than the above, in that we show:
kusano 7d535a
 *   (a) how to modify the JPEG library's standard error-reporting behavior;
kusano 7d535a
 *   (b) how to allocate workspace using the library's memory manager.
kusano 7d535a
 *
kusano 7d535a
 * Just to make this example a little different from the first one, we'll
kusano 7d535a
 * assume that we do not intend to put the whole image into an in-memory
kusano 7d535a
 * buffer, but to send it line-by-line someplace else.  We need a one-
kusano 7d535a
 * scanline-high JSAMPLE array as a work buffer, and we will let the JPEG
kusano 7d535a
 * memory manager allocate it for us.  This approach is actually quite useful
kusano 7d535a
 * because we don't need to remember to deallocate the buffer separately: it
kusano 7d535a
 * will go away automatically when the JPEG object is cleaned up.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * ERROR HANDLING:
kusano 7d535a
 *
kusano 7d535a
 * The JPEG library's standard error handler (jerror.c) is divided into
kusano 7d535a
 * several "methods" which you can override individually.  This lets you
kusano 7d535a
 * adjust the behavior without duplicating a lot of code, which you might
kusano 7d535a
 * have to update with each future release.
kusano 7d535a
 *
kusano 7d535a
 * Our example here shows how to override the "error_exit" method so that
kusano 7d535a
 * control is returned to the library's caller when a fatal error occurs,
kusano 7d535a
 * rather than calling exit() as the standard error_exit method does.
kusano 7d535a
 *
kusano 7d535a
 * We use C's setjmp/longjmp facility to return control.  This means that the
kusano 7d535a
 * routine which calls the JPEG library must first execute a setjmp() call to
kusano 7d535a
 * establish the return point.  We want the replacement error_exit to do a
kusano 7d535a
 * longjmp().  But we need to make the setjmp buffer accessible to the
kusano 7d535a
 * error_exit routine.  To do this, we make a private extension of the
kusano 7d535a
 * standard JPEG error handler object.  (If we were using C++, we'd say we
kusano 7d535a
 * were making a subclass of the regular error handler.)
kusano 7d535a
 *
kusano 7d535a
 * Here's the extended error handler struct:
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
struct my_error_mgr {
kusano 7d535a
  struct jpeg_error_mgr pub;	/* "public" fields */
kusano 7d535a
kusano 7d535a
  jmp_buf setjmp_buffer;	/* for return to caller */
kusano 7d535a
};
kusano 7d535a
kusano 7d535a
typedef struct my_error_mgr * my_error_ptr;
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * Here's the routine that will replace the standard error_exit method:
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
METHODDEF(void)
kusano 7d535a
my_error_exit (j_common_ptr cinfo)
kusano 7d535a
{
kusano 7d535a
  /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
kusano 7d535a
  my_error_ptr myerr = (my_error_ptr) cinfo->err;
kusano 7d535a
kusano 7d535a
  /* Always display the message. */
kusano 7d535a
  /* We could postpone this until after returning, if we chose. */
kusano 7d535a
  (*cinfo->err->output_message) (cinfo);
kusano 7d535a
kusano 7d535a
  /* Return control to the setjmp point */
kusano 7d535a
  longjmp(myerr->setjmp_buffer, 1);
kusano 7d535a
}
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * Sample routine for JPEG decompression.  We assume that the source file name
kusano 7d535a
 * is passed in.  We want to return 1 on success, 0 on error.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
kusano 7d535a
GLOBAL(int)
kusano 7d535a
read_JPEG_file (char * filename)
kusano 7d535a
{
kusano 7d535a
  /* This struct contains the JPEG decompression parameters and pointers to
kusano 7d535a
   * working space (which is allocated as needed by the JPEG library).
kusano 7d535a
   */
kusano 7d535a
  struct jpeg_decompress_struct cinfo;
kusano 7d535a
  /* We use our private extension JPEG error handler.
kusano 7d535a
   * Note that this struct must live as long as the main JPEG parameter
kusano 7d535a
   * struct, to avoid dangling-pointer problems.
kusano 7d535a
   */
kusano 7d535a
  struct my_error_mgr jerr;
kusano 7d535a
  /* More stuff */
kusano 7d535a
  FILE * infile;		/* source file */
kusano 7d535a
  JSAMPARRAY buffer;		/* Output row buffer */
kusano 7d535a
  int row_stride;		/* physical row width in output buffer */
kusano 7d535a
kusano 7d535a
  /* In this example we want to open the input file before doing anything else,
kusano 7d535a
   * so that the setjmp() error recovery below can assume the file is open.
kusano 7d535a
   * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that
kusano 7d535a
   * requires it in order to read binary files.
kusano 7d535a
   */
kusano 7d535a
kusano 7d535a
  if ((infile = fopen(filename, "rb")) == NULL) {
kusano 7d535a
    fprintf(stderr, "can't open %s\n", filename);
kusano 7d535a
    return 0;
kusano 7d535a
  }
kusano 7d535a
kusano 7d535a
  /* Step 1: allocate and initialize JPEG decompression object */
kusano 7d535a
kusano 7d535a
  /* We set up the normal JPEG error routines, then override error_exit. */
kusano 7d535a
  cinfo.err = jpeg_std_error(&jerr.pub);
kusano 7d535a
  jerr.pub.error_exit = my_error_exit;
kusano 7d535a
  /* Establish the setjmp return context for my_error_exit to use. */
kusano 7d535a
  if (setjmp(jerr.setjmp_buffer)) {
kusano 7d535a
    /* If we get here, the JPEG code has signaled an error.
kusano 7d535a
     * We need to clean up the JPEG object, close the input file, and return.
kusano 7d535a
     */
kusano 7d535a
    jpeg_destroy_decompress(&cinfo);
kusano 7d535a
    fclose(infile);
kusano 7d535a
    return 0;
kusano 7d535a
  }
kusano 7d535a
  /* Now we can initialize the JPEG decompression object. */
kusano 7d535a
  jpeg_create_decompress(&cinfo);
kusano 7d535a
kusano 7d535a
  /* Step 2: specify data source (eg, a file) */
kusano 7d535a
kusano 7d535a
  jpeg_stdio_src(&cinfo, infile);
kusano 7d535a
kusano 7d535a
  /* Step 3: read file parameters with jpeg_read_header() */
kusano 7d535a
kusano 7d535a
  (void) jpeg_read_header(&cinfo, TRUE);
kusano 7d535a
  /* We can ignore the return value from jpeg_read_header since
kusano 7d535a
   *   (a) suspension is not possible with the stdio data source, and
kusano 7d535a
   *   (b) we passed TRUE to reject a tables-only JPEG file as an error.
kusano 7d535a
   * See libjpeg.txt for more info.
kusano 7d535a
   */
kusano 7d535a
kusano 7d535a
  /* Step 4: set parameters for decompression */
kusano 7d535a
kusano 7d535a
  /* In this example, we don't need to change any of the defaults set by
kusano 7d535a
   * jpeg_read_header(), so we do nothing here.
kusano 7d535a
   */
kusano 7d535a
kusano 7d535a
  /* Step 5: Start decompressor */
kusano 7d535a
kusano 7d535a
  (void) jpeg_start_decompress(&cinfo);
kusano 7d535a
  /* We can ignore the return value since suspension is not possible
kusano 7d535a
   * with the stdio data source.
kusano 7d535a
   */
kusano 7d535a
kusano 7d535a
  /* We may need to do some setup of our own at this point before reading
kusano 7d535a
   * the data.  After jpeg_start_decompress() we have the correct scaled
kusano 7d535a
   * output image dimensions available, as well as the output colormap
kusano 7d535a
   * if we asked for color quantization.
kusano 7d535a
   * In this example, we need to make an output work buffer of the right size.
kusano 7d535a
   */ 
kusano 7d535a
  /* JSAMPLEs per row in output buffer */
kusano 7d535a
  row_stride = cinfo.output_width * cinfo.output_components;
kusano 7d535a
  /* Make a one-row-high sample array that will go away when done with image */
kusano 7d535a
  buffer = (*cinfo.mem->alloc_sarray)
kusano 7d535a
		((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
kusano 7d535a
kusano 7d535a
  /* Step 6: while (scan lines remain to be read) */
kusano 7d535a
  /*           jpeg_read_scanlines(...); */
kusano 7d535a
kusano 7d535a
  /* Here we use the library's state variable cinfo.output_scanline as the
kusano 7d535a
   * loop counter, so that we don't have to keep track ourselves.
kusano 7d535a
   */
kusano 7d535a
  while (cinfo.output_scanline < cinfo.output_height) {
kusano 7d535a
    /* jpeg_read_scanlines expects an array of pointers to scanlines.
kusano 7d535a
     * Here the array is only one element long, but you could ask for
kusano 7d535a
     * more than one scanline at a time if that's more convenient.
kusano 7d535a
     */
kusano 7d535a
    (void) jpeg_read_scanlines(&cinfo, buffer, 1);
kusano 7d535a
    /* Assume put_scanline_someplace wants a pointer and sample count. */
kusano 7d535a
    put_scanline_someplace(buffer[0], row_stride);
kusano 7d535a
  }
kusano 7d535a
kusano 7d535a
  /* Step 7: Finish decompression */
kusano 7d535a
kusano 7d535a
  (void) jpeg_finish_decompress(&cinfo);
kusano 7d535a
  /* We can ignore the return value since suspension is not possible
kusano 7d535a
   * with the stdio data source.
kusano 7d535a
   */
kusano 7d535a
kusano 7d535a
  /* Step 8: Release JPEG decompression object */
kusano 7d535a
kusano 7d535a
  /* This is an important step since it will release a good deal of memory. */
kusano 7d535a
  jpeg_destroy_decompress(&cinfo);
kusano 7d535a
kusano 7d535a
  /* After finish_decompress, we can close the input file.
kusano 7d535a
   * Here we postpone it until after no more JPEG errors are possible,
kusano 7d535a
   * so as to simplify the setjmp error logic above.  (Actually, I don't
kusano 7d535a
   * think that jpeg_destroy can do an error exit, but why assume anything...)
kusano 7d535a
   */
kusano 7d535a
  fclose(infile);
kusano 7d535a
kusano 7d535a
  /* At this point you may want to check to see whether any corrupt-data
kusano 7d535a
   * warnings occurred (test whether jerr.pub.num_warnings is nonzero).
kusano 7d535a
   */
kusano 7d535a
kusano 7d535a
  /* And we're done! */
kusano 7d535a
  return 1;
kusano 7d535a
}
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * SOME FINE POINTS:
kusano 7d535a
 *
kusano 7d535a
 * In the above code, we ignored the return value of jpeg_read_scanlines,
kusano 7d535a
 * which is the number of scanlines actually read.  We could get away with
kusano 7d535a
 * this because we asked for only one line at a time and we weren't using
kusano 7d535a
 * a suspending data source.  See libjpeg.txt for more info.
kusano 7d535a
 *
kusano 7d535a
 * We cheated a bit by calling alloc_sarray() after jpeg_start_decompress();
kusano 7d535a
 * we should have done it beforehand to ensure that the space would be
kusano 7d535a
 * counted against the JPEG max_memory setting.  In some systems the above
kusano 7d535a
 * code would risk an out-of-memory error.  However, in general we don't
kusano 7d535a
 * know the output image dimensions before jpeg_start_decompress(), unless we
kusano 7d535a
 * call jpeg_calc_output_dimensions().  See libjpeg.txt for more about this.
kusano 7d535a
 *
kusano 7d535a
 * Scanlines are returned in the same order as they appear in the JPEG file,
kusano 7d535a
 * which is standardly top-to-bottom.  If you must emit data bottom-to-top,
kusano 7d535a
 * you can use one of the virtual arrays provided by the JPEG memory manager
kusano 7d535a
 * to invert the data.  See wrbmp.c for an example.
kusano 7d535a
 *
kusano 7d535a
 * As with compression, some operating modes may require temporary files.
kusano 7d535a
 * On some systems you may need to set up a signal handler to ensure that
kusano 7d535a
 * temporary files are deleted if the program is interrupted.  See libjpeg.txt.
kusano 7d535a
 */