Blame gtkmm-osx/jpeg-6b/rdtarga.c

darco 56a656
/*
darco 56a656
 * rdtarga.c
darco 56a656
 *
darco 56a656
 * Copyright (C) 1991-1996, Thomas G. Lane.
darco 56a656
 * This file is part of the Independent JPEG Group's software.
darco 56a656
 * For conditions of distribution and use, see the accompanying README file.
darco 56a656
 *
darco 56a656
 * This file contains routines to read input images in Targa format.
darco 56a656
 *
darco 56a656
 * These routines may need modification for non-Unix environments or
darco 56a656
 * specialized applications.  As they stand, they assume input from
darco 56a656
 * an ordinary stdio stream.  They further assume that reading begins
darco 56a656
 * at the start of the file; start_input may need work if the
darco 56a656
 * user interface has already read some data (e.g., to determine that
darco 56a656
 * the file is indeed Targa format).
darco 56a656
 *
darco 56a656
 * Based on code contributed by Lee Daniel Crocker.
darco 56a656
 */
darco 56a656
darco 56a656
#include "cdjpeg.h"		/* Common decls for cjpeg/djpeg applications */
darco 56a656
darco 56a656
#ifdef TARGA_SUPPORTED
darco 56a656
darco 56a656
darco 56a656
/* Macros to deal with unsigned chars as efficiently as compiler allows */
darco 56a656
darco 56a656
#ifdef HAVE_UNSIGNED_CHAR
darco 56a656
typedef unsigned char U_CHAR;
darco 56a656
#define UCH(x)	((int) (x))
darco 56a656
#else /* !HAVE_UNSIGNED_CHAR */
darco 56a656
#ifdef CHAR_IS_UNSIGNED
darco 56a656
typedef char U_CHAR;
darco 56a656
#define UCH(x)	((int) (x))
darco 56a656
#else
darco 56a656
typedef char U_CHAR;
darco 56a656
#define UCH(x)	((int) (x) & 0xFF)
darco 56a656
#endif
darco 56a656
#endif /* HAVE_UNSIGNED_CHAR */
darco 56a656
darco 56a656
darco 56a656
#define	ReadOK(file,buffer,len)	(JFREAD(file,buffer,len) == ((size_t) (len)))
darco 56a656
darco 56a656
darco 56a656
/* Private version of data source object */
darco 56a656
darco 56a656
typedef struct _tga_source_struct * tga_source_ptr;
darco 56a656
darco 56a656
typedef struct _tga_source_struct {
darco 56a656
  struct cjpeg_source_struct pub; /* public fields */
darco 56a656
darco 56a656
  j_compress_ptr cinfo;		/* back link saves passing separate parm */
darco 56a656
darco 56a656
  JSAMPARRAY colormap;		/* Targa colormap (converted to my format) */
darco 56a656
darco 56a656
  jvirt_sarray_ptr whole_image;	/* Needed if funny input row order */
darco 56a656
  JDIMENSION current_row;	/* Current logical row number to read */
darco 56a656
darco 56a656
  /* Pointer to routine to extract next Targa pixel from input file */
darco 56a656
  JMETHOD(void, read_pixel, (tga_source_ptr sinfo));
darco 56a656
darco 56a656
  /* Result of read_pixel is delivered here: */
darco 56a656
  U_CHAR tga_pixel[4];
darco 56a656
darco 56a656
  int pixel_size;		/* Bytes per Targa pixel (1 to 4) */
darco 56a656
darco 56a656
  /* State info for reading RLE-coded pixels; both counts must be init to 0 */
darco 56a656
  int block_count;		/* # of pixels remaining in RLE block */
darco 56a656
  int dup_pixel_count;		/* # of times to duplicate previous pixel */
darco 56a656
darco 56a656
  /* This saves the correct pixel-row-expansion method for preload_image */
darco 56a656
  JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo,
darco 56a656
				       cjpeg_source_ptr sinfo));
darco 56a656
} tga_source_struct;
darco 56a656
darco 56a656
darco 56a656
/* For expanding 5-bit pixel values to 8-bit with best rounding */
darco 56a656
darco 56a656
static const UINT8 c5to8bits[32] = {
darco 56a656
    0,   8,  16,  25,  33,  41,  49,  58,
darco 56a656
   66,  74,  82,  90,  99, 107, 115, 123,
darco 56a656
  132, 140, 148, 156, 165, 173, 181, 189,
darco 56a656
  197, 206, 214, 222, 230, 239, 247, 255
darco 56a656
};
darco 56a656
darco 56a656
darco 56a656
darco 56a656
LOCAL(int)
darco 56a656
read_byte (tga_source_ptr sinfo)
darco 56a656
/* Read next byte from Targa file */
darco 56a656
{
darco 56a656
  register FILE *infile = sinfo->pub.input_file;
darco 56a656
  register int c;
darco 56a656
darco 56a656
  if ((c = getc(infile)) == EOF)
darco 56a656
    ERREXIT(sinfo->cinfo, JERR_INPUT_EOF);
darco 56a656
  return c;
darco 56a656
}
darco 56a656
darco 56a656
darco 56a656
LOCAL(void)
darco 56a656
read_colormap (tga_source_ptr sinfo, int cmaplen, int mapentrysize)
darco 56a656
/* Read the colormap from a Targa file */
darco 56a656
{
darco 56a656
  int i;
darco 56a656
darco 56a656
  /* Presently only handles 24-bit BGR format */
darco 56a656
  if (mapentrysize != 24)
darco 56a656
    ERREXIT(sinfo->cinfo, JERR_TGA_BADCMAP);
darco 56a656
darco 56a656
  for (i = 0; i < cmaplen; i++) {
darco 56a656
    sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo);
darco 56a656
    sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo);
darco 56a656
    sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo);
darco 56a656
  }
darco 56a656
}
darco 56a656
darco 56a656
darco 56a656
/*
darco 56a656
 * read_pixel methods: get a single pixel from Targa file into tga_pixel[]
darco 56a656
 */
darco 56a656
darco 56a656
METHODDEF(void)
darco 56a656
read_non_rle_pixel (tga_source_ptr sinfo)
darco 56a656
/* Read one Targa pixel from the input file; no RLE expansion */
darco 56a656
{
darco 56a656
  register FILE *infile = sinfo->pub.input_file;
darco 56a656
  register int i;
darco 56a656
darco 56a656
  for (i = 0; i < sinfo->pixel_size; i++) {
darco 56a656
    sinfo->tga_pixel[i] = (U_CHAR) getc(infile);
darco 56a656
  }
darco 56a656
}
darco 56a656
darco 56a656
darco 56a656
METHODDEF(void)
darco 56a656
read_rle_pixel (tga_source_ptr sinfo)
darco 56a656
/* Read one Targa pixel from the input file, expanding RLE data as needed */
darco 56a656
{
darco 56a656
  register FILE *infile = sinfo->pub.input_file;
darco 56a656
  register int i;
darco 56a656
darco 56a656
  /* Duplicate previously read pixel? */
darco 56a656
  if (sinfo->dup_pixel_count > 0) {
darco 56a656
    sinfo->dup_pixel_count--;
darco 56a656
    return;
darco 56a656
  }
darco 56a656
darco 56a656
  /* Time to read RLE block header? */
darco 56a656
  if (--sinfo->block_count < 0) { /* decrement pixels remaining in block */
darco 56a656
    i = read_byte(sinfo);
darco 56a656
    if (i & 0x80) {		/* Start of duplicate-pixel block? */
darco 56a656
      sinfo->dup_pixel_count = i & 0x7F; /* number of dups after this one */
darco 56a656
      sinfo->block_count = 0;	/* then read new block header */
darco 56a656
    } else {
darco 56a656
      sinfo->block_count = i & 0x7F; /* number of pixels after this one */
darco 56a656
    }
darco 56a656
  }
darco 56a656
darco 56a656
  /* Read next pixel */
darco 56a656
  for (i = 0; i < sinfo->pixel_size; i++) {
darco 56a656
    sinfo->tga_pixel[i] = (U_CHAR) getc(infile);
darco 56a656
  }
darco 56a656
}
darco 56a656
darco 56a656
darco 56a656
/*
darco 56a656
 * Read one row of pixels.
darco 56a656
 *
darco 56a656
 * We provide several different versions depending on input file format.
darco 56a656
 */
darco 56a656
darco 56a656
darco 56a656
METHODDEF(JDIMENSION)
darco 56a656
get_8bit_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
darco 56a656
/* This version is for reading 8-bit grayscale pixels */
darco 56a656
{
darco 56a656
  tga_source_ptr source = (tga_source_ptr) sinfo;
darco 56a656
  register JSAMPROW ptr;
darco 56a656
  register JDIMENSION col;
darco 56a656
  
darco 56a656
  ptr = source->pub.buffer[0];
darco 56a656
  for (col = cinfo->image_width; col > 0; col--) {
darco 56a656
    (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
darco 56a656
    *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]);
darco 56a656
  }
darco 56a656
  return 1;
darco 56a656
}
darco 56a656
darco 56a656
METHODDEF(JDIMENSION)
darco 56a656
get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
darco 56a656
/* This version is for reading 8-bit colormap indexes */
darco 56a656
{
darco 56a656
  tga_source_ptr source = (tga_source_ptr) sinfo;
darco 56a656
  register int t;
darco 56a656
  register JSAMPROW ptr;
darco 56a656
  register JDIMENSION col;
darco 56a656
  register JSAMPARRAY colormap = source->colormap;
darco 56a656
darco 56a656
  ptr = source->pub.buffer[0];
darco 56a656
  for (col = cinfo->image_width; col > 0; col--) {
darco 56a656
    (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
darco 56a656
    t = UCH(source->tga_pixel[0]);
darco 56a656
    *ptr++ = colormap[0][t];
darco 56a656
    *ptr++ = colormap[1][t];
darco 56a656
    *ptr++ = colormap[2][t];
darco 56a656
  }
darco 56a656
  return 1;
darco 56a656
}
darco 56a656
darco 56a656
METHODDEF(JDIMENSION)
darco 56a656
get_16bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
darco 56a656
/* This version is for reading 16-bit pixels */
darco 56a656
{
darco 56a656
  tga_source_ptr source = (tga_source_ptr) sinfo;
darco 56a656
  register int t;
darco 56a656
  register JSAMPROW ptr;
darco 56a656
  register JDIMENSION col;
darco 56a656
  
darco 56a656
  ptr = source->pub.buffer[0];
darco 56a656
  for (col = cinfo->image_width; col > 0; col--) {
darco 56a656
    (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
darco 56a656
    t = UCH(source->tga_pixel[0]);
darco 56a656
    t += UCH(source->tga_pixel[1]) << 8;
darco 56a656
    /* We expand 5 bit data to 8 bit sample width.
darco 56a656
     * The format of the 16-bit (LSB first) input word is
darco 56a656
     *     xRRRRRGGGGGBBBBB
darco 56a656
     */
darco 56a656
    ptr[2] = (JSAMPLE) c5to8bits[t & 0x1F];
darco 56a656
    t >>= 5;
darco 56a656
    ptr[1] = (JSAMPLE) c5to8bits[t & 0x1F];
darco 56a656
    t >>= 5;
darco 56a656
    ptr[0] = (JSAMPLE) c5to8bits[t & 0x1F];
darco 56a656
    ptr += 3;
darco 56a656
  }
darco 56a656
  return 1;
darco 56a656
}
darco 56a656
darco 56a656
METHODDEF(JDIMENSION)
darco 56a656
get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
darco 56a656
/* This version is for reading 24-bit pixels */
darco 56a656
{
darco 56a656
  tga_source_ptr source = (tga_source_ptr) sinfo;
darco 56a656
  register JSAMPROW ptr;
darco 56a656
  register JDIMENSION col;
darco 56a656
  
darco 56a656
  ptr = source->pub.buffer[0];
darco 56a656
  for (col = cinfo->image_width; col > 0; col--) {
darco 56a656
    (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
darco 56a656
    *ptr++ = (JSAMPLE) UCH(source->tga_pixel[2]); /* change BGR to RGB order */
darco 56a656
    *ptr++ = (JSAMPLE) UCH(source->tga_pixel[1]);
darco 56a656
    *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]);
darco 56a656
  }
darco 56a656
  return 1;
darco 56a656
}
darco 56a656
darco 56a656
/*
darco 56a656
 * Targa also defines a 32-bit pixel format with order B,G,R,A.
darco 56a656
 * We presently ignore the attribute byte, so the code for reading
darco 56a656
 * these pixels is identical to the 24-bit routine above.
darco 56a656
 * This works because the actual pixel length is only known to read_pixel.
darco 56a656
 */
darco 56a656
darco 56a656
#define get_32bit_row  get_24bit_row
darco 56a656
darco 56a656
darco 56a656
/*
darco 56a656
 * This method is for re-reading the input data in standard top-down
darco 56a656
 * row order.  The entire image has already been read into whole_image
darco 56a656
 * with proper conversion of pixel format, but it's in a funny row order.
darco 56a656
 */
darco 56a656
darco 56a656
METHODDEF(JDIMENSION)
darco 56a656
get_memory_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
darco 56a656
{
darco 56a656
  tga_source_ptr source = (tga_source_ptr) sinfo;
darco 56a656
  JDIMENSION source_row;
darco 56a656
darco 56a656
  /* Compute row of source that maps to current_row of normal order */
darco 56a656
  /* For now, assume image is bottom-up and not interlaced. */
darco 56a656
  /* NEEDS WORK to support interlaced images! */
darco 56a656
  source_row = cinfo->image_height - source->current_row - 1;
darco 56a656
darco 56a656
  /* Fetch that row from virtual array */
darco 56a656
  source->pub.buffer = (*cinfo->mem->access_virt_sarray)
darco 56a656
    ((j_common_ptr) cinfo, source->whole_image,
darco 56a656
     source_row, (JDIMENSION) 1, FALSE);
darco 56a656
darco 56a656
  source->current_row++;
darco 56a656
  return 1;
darco 56a656
}
darco 56a656
darco 56a656
darco 56a656
/*
darco 56a656
 * This method loads the image into whole_image during the first call on
darco 56a656
 * get_pixel_rows.  The get_pixel_rows pointer is then adjusted to call
darco 56a656
 * get_memory_row on subsequent calls.
darco 56a656
 */
darco 56a656
darco 56a656
METHODDEF(JDIMENSION)
darco 56a656
preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
darco 56a656
{
darco 56a656
  tga_source_ptr source = (tga_source_ptr) sinfo;
darco 56a656
  JDIMENSION row;
darco 56a656
  cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress;
darco 56a656
darco 56a656
  /* Read the data into a virtual array in input-file row order. */
darco 56a656
  for (row = 0; row < cinfo->image_height; row++) {
darco 56a656
    if (progress != NULL) {
darco 56a656
      progress->pub.pass_counter = (long) row;
darco 56a656
      progress->pub.pass_limit = (long) cinfo->image_height;
darco 56a656
      (*progress->pub.progress_monitor) ((j_common_ptr) cinfo);
darco 56a656
    }
darco 56a656
    source->pub.buffer = (*cinfo->mem->access_virt_sarray)
darco 56a656
      ((j_common_ptr) cinfo, source->whole_image, row, (JDIMENSION) 1, TRUE);
darco 56a656
    (*source->get_pixel_rows) (cinfo, sinfo);
darco 56a656
  }
darco 56a656
  if (progress != NULL)
darco 56a656
    progress->completed_extra_passes++;
darco 56a656
darco 56a656
  /* Set up to read from the virtual array in unscrambled order */
darco 56a656
  source->pub.get_pixel_rows = get_memory_row;
darco 56a656
  source->current_row = 0;
darco 56a656
  /* And read the first row */
darco 56a656
  return get_memory_row(cinfo, sinfo);
darco 56a656
}
darco 56a656
darco 56a656
darco 56a656
/*
darco 56a656
 * Read the file header; return image size and component count.
darco 56a656
 */
darco 56a656
darco 56a656
METHODDEF(void)
darco 56a656
start_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
darco 56a656
{
darco 56a656
  tga_source_ptr source = (tga_source_ptr) sinfo;
darco 56a656
  U_CHAR targaheader[18];
darco 56a656
  int idlen, cmaptype, subtype, flags, interlace_type, components;
darco 56a656
  unsigned int width, height, maplen;
darco 56a656
  boolean is_bottom_up;
darco 56a656
darco 56a656
#define GET_2B(offset)	((unsigned int) UCH(targaheader[offset]) + \
darco 56a656
			 (((unsigned int) UCH(targaheader[offset+1])) << 8))
darco 56a656
darco 56a656
  if (! ReadOK(source->pub.input_file, targaheader, 18))
darco 56a656
    ERREXIT(cinfo, JERR_INPUT_EOF);
darco 56a656
darco 56a656
  /* Pretend "15-bit" pixels are 16-bit --- we ignore attribute bit anyway */
darco 56a656
  if (targaheader[16] == 15)
darco 56a656
    targaheader[16] = 16;
darco 56a656
darco 56a656
  idlen = UCH(targaheader[0]);
darco 56a656
  cmaptype = UCH(targaheader[1]);
darco 56a656
  subtype = UCH(targaheader[2]);
darco 56a656
  maplen = GET_2B(5);
darco 56a656
  width = GET_2B(12);
darco 56a656
  height = GET_2B(14);
darco 56a656
  source->pixel_size = UCH(targaheader[16]) >> 3;
darco 56a656
  flags = UCH(targaheader[17]);	/* Image Descriptor byte */
darco 56a656
darco 56a656
  is_bottom_up = ((flags & 0x20) == 0);	/* bit 5 set => top-down */
darco 56a656
  interlace_type = flags >> 6;	/* bits 6/7 are interlace code */
darco 56a656
darco 56a656
  if (cmaptype > 1 ||		/* cmaptype must be 0 or 1 */
darco 56a656
      source->pixel_size < 1 || source->pixel_size > 4 ||
darco 56a656
      (UCH(targaheader[16]) & 7) != 0 || /* bits/pixel must be multiple of 8 */
darco 56a656
      interlace_type != 0)	/* currently don't allow interlaced image */
darco 56a656
    ERREXIT(cinfo, JERR_TGA_BADPARMS);
darco 56a656
  
darco 56a656
  if (subtype > 8) {
darco 56a656
    /* It's an RLE-coded file */
darco 56a656
    source->read_pixel = read_rle_pixel;
darco 56a656
    source->block_count = source->dup_pixel_count = 0;
darco 56a656
    subtype -= 8;
darco 56a656
  } else {
darco 56a656
    /* Non-RLE file */
darco 56a656
    source->read_pixel = read_non_rle_pixel;
darco 56a656
  }
darco 56a656
darco 56a656
  /* Now should have subtype 1, 2, or 3 */
darco 56a656
  components = 3;		/* until proven different */
darco 56a656
  cinfo->in_color_space = JCS_RGB;
darco 56a656
darco 56a656
  switch (subtype) {
darco 56a656
  case 1:			/* Colormapped image */
darco 56a656
    if (source->pixel_size == 1 && cmaptype == 1)
darco 56a656
      source->get_pixel_rows = get_8bit_row;
darco 56a656
    else
darco 56a656
      ERREXIT(cinfo, JERR_TGA_BADPARMS);
darco 56a656
    TRACEMS2(cinfo, 1, JTRC_TGA_MAPPED, width, height);
darco 56a656
    break;
darco 56a656
  case 2:			/* RGB image */
darco 56a656
    switch (source->pixel_size) {
darco 56a656
    case 2:
darco 56a656
      source->get_pixel_rows = get_16bit_row;
darco 56a656
      break;
darco 56a656
    case 3:
darco 56a656
      source->get_pixel_rows = get_24bit_row;
darco 56a656
      break;
darco 56a656
    case 4:
darco 56a656
      source->get_pixel_rows = get_32bit_row;
darco 56a656
      break;
darco 56a656
    default:
darco 56a656
      ERREXIT(cinfo, JERR_TGA_BADPARMS);
darco 56a656
      break;
darco 56a656
    }
darco 56a656
    TRACEMS2(cinfo, 1, JTRC_TGA, width, height);
darco 56a656
    break;
darco 56a656
  case 3:			/* Grayscale image */
darco 56a656
    components = 1;
darco 56a656
    cinfo->in_color_space = JCS_GRAYSCALE;
darco 56a656
    if (source->pixel_size == 1)
darco 56a656
      source->get_pixel_rows = get_8bit_gray_row;
darco 56a656
    else
darco 56a656
      ERREXIT(cinfo, JERR_TGA_BADPARMS);
darco 56a656
    TRACEMS2(cinfo, 1, JTRC_TGA_GRAY, width, height);
darco 56a656
    break;
darco 56a656
  default:
darco 56a656
    ERREXIT(cinfo, JERR_TGA_BADPARMS);
darco 56a656
    break;
darco 56a656
  }
darco 56a656
darco 56a656
  if (is_bottom_up) {
darco 56a656
    /* Create a virtual array to buffer the upside-down image. */
darco 56a656
    source->whole_image = (*cinfo->mem->request_virt_sarray)
darco 56a656
      ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
darco 56a656
       (JDIMENSION) width * components, (JDIMENSION) height, (JDIMENSION) 1);
darco 56a656
    if (cinfo->progress != NULL) {
darco 56a656
      cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress;
darco 56a656
      progress->total_extra_passes++; /* count file input as separate pass */
darco 56a656
    }
darco 56a656
    /* source->pub.buffer will point to the virtual array. */
darco 56a656
    source->pub.buffer_height = 1; /* in case anyone looks at it */
darco 56a656
    source->pub.get_pixel_rows = preload_image;
darco 56a656
  } else {
darco 56a656
    /* Don't need a virtual array, but do need a one-row input buffer. */
darco 56a656
    source->whole_image = NULL;
darco 56a656
    source->pub.buffer = (*cinfo->mem->alloc_sarray)
darco 56a656
      ((j_common_ptr) cinfo, JPOOL_IMAGE,
darco 56a656
       (JDIMENSION) width * components, (JDIMENSION) 1);
darco 56a656
    source->pub.buffer_height = 1;
darco 56a656
    source->pub.get_pixel_rows = source->get_pixel_rows;
darco 56a656
  }
darco 56a656
  
darco 56a656
  while (idlen--)		/* Throw away ID field */
darco 56a656
    (void) read_byte(source);
darco 56a656
darco 56a656
  if (maplen > 0) {
darco 56a656
    if (maplen > 256 || GET_2B(3) != 0)
darco 56a656
      ERREXIT(cinfo, JERR_TGA_BADCMAP);
darco 56a656
    /* Allocate space to store the colormap */
darco 56a656
    source->colormap = (*cinfo->mem->alloc_sarray)
darco 56a656
      ((j_common_ptr) cinfo, JPOOL_IMAGE, (JDIMENSION) maplen, (JDIMENSION) 3);
darco 56a656
    /* and read it from the file */
darco 56a656
    read_colormap(source, (int) maplen, UCH(targaheader[7]));
darco 56a656
  } else {
darco 56a656
    if (cmaptype)		/* but you promised a cmap! */
darco 56a656
      ERREXIT(cinfo, JERR_TGA_BADPARMS);
darco 56a656
    source->colormap = NULL;
darco 56a656
  }
darco 56a656
darco 56a656
  cinfo->input_components = components;
darco 56a656
  cinfo->data_precision = 8;
darco 56a656
  cinfo->image_width = width;
darco 56a656
  cinfo->image_height = height;
darco 56a656
}
darco 56a656
darco 56a656
darco 56a656
/*
darco 56a656
 * Finish up at the end of the file.
darco 56a656
 */
darco 56a656
darco 56a656
METHODDEF(void)
darco 56a656
finish_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
darco 56a656
{
darco 56a656
  /* no work */
darco 56a656
}
darco 56a656
darco 56a656
darco 56a656
/*
darco 56a656
 * The module selection routine for Targa format input.
darco 56a656
 */
darco 56a656
darco 56a656
GLOBAL(cjpeg_source_ptr)
darco 56a656
jinit_read_targa (j_compress_ptr cinfo)
darco 56a656
{
darco 56a656
  tga_source_ptr source;
darco 56a656
darco 56a656
  /* Create module interface object */
darco 56a656
  source = (tga_source_ptr)
darco 56a656
      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
darco 56a656
				  SIZEOF(tga_source_struct));
darco 56a656
  source->cinfo = cinfo;	/* make back link for subroutines */
darco 56a656
  /* Fill in method ptrs, except get_pixel_rows which start_input sets */
darco 56a656
  source->pub.start_input = start_input_tga;
darco 56a656
  source->pub.finish_input = finish_input_tga;
darco 56a656
darco 56a656
  return (cjpeg_source_ptr) source;
darco 56a656
}
darco 56a656
darco 56a656
#endif /* TARGA_SUPPORTED */