Remove code for the obsolete RLE image format
libjpeg-turbo never included that code, because it requires an external library (the Utah Raster Toolkit.) The RLE image format was supplanted by GIF in the late 1980s, so it is rarely seen these days. (It had a lousy Weissman score, anyhow.)
This commit is contained in:
17
cderror.h
17
cderror.h
@@ -84,23 +84,6 @@ JMESSAGE(JTRC_PPM, "%ux%u PPM image")
|
|||||||
JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image")
|
JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image")
|
||||||
#endif /* PPM_SUPPORTED */
|
#endif /* PPM_SUPPORTED */
|
||||||
|
|
||||||
#ifdef RLE_SUPPORTED
|
|
||||||
JMESSAGE(JERR_RLE_BADERROR, "Bogus error code from RLE library")
|
|
||||||
JMESSAGE(JERR_RLE_COLORSPACE, "RLE output must be grayscale or RGB")
|
|
||||||
JMESSAGE(JERR_RLE_DIMENSIONS, "Image dimensions (%ux%u) too large for RLE")
|
|
||||||
JMESSAGE(JERR_RLE_EMPTY, "Empty RLE file")
|
|
||||||
JMESSAGE(JERR_RLE_EOF, "Premature EOF in RLE header")
|
|
||||||
JMESSAGE(JERR_RLE_MEM, "Insufficient memory for RLE header")
|
|
||||||
JMESSAGE(JERR_RLE_NOT, "Not an RLE file")
|
|
||||||
JMESSAGE(JERR_RLE_TOOMANYCHANNELS, "Cannot handle %d output channels for RLE")
|
|
||||||
JMESSAGE(JERR_RLE_UNSUPPORTED, "Cannot handle this RLE setup")
|
|
||||||
JMESSAGE(JTRC_RLE, "%ux%u full-color RLE file")
|
|
||||||
JMESSAGE(JTRC_RLE_FULLMAP, "%ux%u full-color RLE file with map of length %d")
|
|
||||||
JMESSAGE(JTRC_RLE_GRAY, "%ux%u grayscale RLE file")
|
|
||||||
JMESSAGE(JTRC_RLE_MAPGRAY, "%ux%u grayscale RLE file with map of length %d")
|
|
||||||
JMESSAGE(JTRC_RLE_MAPPED, "%ux%u colormapped RLE file with map of length %d")
|
|
||||||
#endif /* RLE_SUPPORTED */
|
|
||||||
|
|
||||||
#ifdef TARGA_SUPPORTED
|
#ifdef TARGA_SUPPORTED
|
||||||
JMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format")
|
JMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format")
|
||||||
JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file")
|
JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file")
|
||||||
|
|||||||
8
cdjpeg.h
8
cdjpeg.h
@@ -56,9 +56,9 @@ struct djpeg_dest_struct {
|
|||||||
void (*finish_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
|
void (*finish_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
|
||||||
/* Re-calculate buffer dimensions based on output dimensions (for use with
|
/* Re-calculate buffer dimensions based on output dimensions (for use with
|
||||||
partial image decompression.) If this is NULL, then the output format
|
partial image decompression.) If this is NULL, then the output format
|
||||||
does not support partial image decompression (BMP and RLE, in particular,
|
does not support partial image decompression (BMP, in particular, cannot
|
||||||
cannot support partial decompression because they use an inversion buffer
|
support partial decompression because it uses an inversion buffer to write
|
||||||
to write the image in bottom-up order.) */
|
the image in bottom-up order.) */
|
||||||
void (*calc_buffer_dimensions) (j_decompress_ptr cinfo,
|
void (*calc_buffer_dimensions) (j_decompress_ptr cinfo,
|
||||||
djpeg_dest_ptr dinfo);
|
djpeg_dest_ptr dinfo);
|
||||||
|
|
||||||
@@ -107,8 +107,6 @@ EXTERN(cjpeg_source_ptr) jinit_read_gif(j_compress_ptr cinfo);
|
|||||||
EXTERN(djpeg_dest_ptr) jinit_write_gif(j_decompress_ptr cinfo);
|
EXTERN(djpeg_dest_ptr) jinit_write_gif(j_decompress_ptr cinfo);
|
||||||
EXTERN(cjpeg_source_ptr) jinit_read_ppm(j_compress_ptr cinfo);
|
EXTERN(cjpeg_source_ptr) jinit_read_ppm(j_compress_ptr cinfo);
|
||||||
EXTERN(djpeg_dest_ptr) jinit_write_ppm(j_decompress_ptr cinfo);
|
EXTERN(djpeg_dest_ptr) jinit_write_ppm(j_decompress_ptr cinfo);
|
||||||
EXTERN(cjpeg_source_ptr) jinit_read_rle(j_compress_ptr cinfo);
|
|
||||||
EXTERN(djpeg_dest_ptr) jinit_write_rle(j_decompress_ptr cinfo);
|
|
||||||
EXTERN(cjpeg_source_ptr) jinit_read_targa(j_compress_ptr cinfo);
|
EXTERN(cjpeg_source_ptr) jinit_read_targa(j_compress_ptr cinfo);
|
||||||
EXTERN(djpeg_dest_ptr) jinit_write_targa(j_decompress_ptr cinfo);
|
EXTERN(djpeg_dest_ptr) jinit_write_targa(j_decompress_ptr cinfo);
|
||||||
|
|
||||||
|
|||||||
3
cjpeg.1
3
cjpeg.1
@@ -16,8 +16,7 @@ cjpeg \- compress an image file to a JPEG file
|
|||||||
compresses the named image file, or the standard input if no file is
|
compresses the named image file, or the standard input if no file is
|
||||||
named, and produces a JPEG/JFIF file on the standard output.
|
named, and produces a JPEG/JFIF file on the standard output.
|
||||||
The currently supported input file formats are: PPM (PBMPLUS color
|
The currently supported input file formats are: PPM (PBMPLUS color
|
||||||
format), PGM (PBMPLUS grayscale format), BMP, Targa, and RLE (Utah Raster
|
format), PGM (PBMPLUS grayscale format), BMP, and Targa.
|
||||||
Toolkit format). (RLE is supported only if the URT library is available.)
|
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
All switch names may be abbreviated; for example,
|
All switch names may be abbreviated; for example,
|
||||||
.B \-grayscale
|
.B \-grayscale
|
||||||
|
|||||||
8
cjpeg.c
8
cjpeg.c
@@ -69,9 +69,9 @@ static const char * const cdjpeg_message_table[] = {
|
|||||||
* 2) assume we can push back more than one character (works in
|
* 2) assume we can push back more than one character (works in
|
||||||
* some C implementations, but unportable);
|
* some C implementations, but unportable);
|
||||||
* 3) provide our own buffering (breaks input readers that want to use
|
* 3) provide our own buffering (breaks input readers that want to use
|
||||||
* stdio directly, such as the RLE library);
|
* stdio directly);
|
||||||
* or 4) don't put back the data, and modify the input_init methods to assume
|
* or 4) don't put back the data, and modify the input_init methods to assume
|
||||||
* they start reading after the start of file (also breaks RLE library).
|
* they start reading after the start of file.
|
||||||
* #1 is attractive for MS-DOS but is untenable on Unix.
|
* #1 is attractive for MS-DOS but is untenable on Unix.
|
||||||
*
|
*
|
||||||
* The most portable solution for file types that can't be identified by their
|
* The most portable solution for file types that can't be identified by their
|
||||||
@@ -117,10 +117,6 @@ select_file_type(j_compress_ptr cinfo, FILE *infile)
|
|||||||
case 'P':
|
case 'P':
|
||||||
return jinit_read_ppm(cinfo);
|
return jinit_read_ppm(cinfo);
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLE_SUPPORTED
|
|
||||||
case 'R':
|
|
||||||
return jinit_read_rle(cinfo);
|
|
||||||
#endif
|
|
||||||
#ifdef TARGA_SUPPORTED
|
#ifdef TARGA_SUPPORTED
|
||||||
case 0x00:
|
case 0x00:
|
||||||
return jinit_read_targa(cinfo);
|
return jinit_read_targa(cinfo);
|
||||||
|
|||||||
6
djpeg.1
6
djpeg.1
@@ -15,8 +15,7 @@ djpeg \- decompress a JPEG file to an image file
|
|||||||
.B djpeg
|
.B djpeg
|
||||||
decompresses the named JPEG file, or the standard input if no file is named,
|
decompresses the named JPEG file, or the standard input if no file is named,
|
||||||
and produces an image file on the standard output. PBMPLUS (PPM/PGM), BMP,
|
and produces an image file on the standard output. PBMPLUS (PPM/PGM), BMP,
|
||||||
GIF, Targa, or RLE (Utah Raster Toolkit) output format can be selected.
|
GIF, or Targa output format can be selected.
|
||||||
(RLE is supported only if the URT library is available.)
|
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
All switch names may be abbreviated; for example,
|
All switch names may be abbreviated; for example,
|
||||||
.B \-grayscale
|
.B \-grayscale
|
||||||
@@ -100,9 +99,6 @@ PGM is emitted if the JPEG file is grayscale or if
|
|||||||
.B \-grayscale
|
.B \-grayscale
|
||||||
is specified; otherwise PPM is emitted.
|
is specified; otherwise PPM is emitted.
|
||||||
.TP
|
.TP
|
||||||
.B \-rle
|
|
||||||
Select RLE output format. (Requires URT library.)
|
|
||||||
.TP
|
|
||||||
.B \-targa
|
.B \-targa
|
||||||
Select Targa output format. Grayscale format is emitted if the JPEG file is
|
Select Targa output format. Grayscale format is emitted if the JPEG file is
|
||||||
grayscale or if
|
grayscale or if
|
||||||
|
|||||||
14
djpeg.c
14
djpeg.c
@@ -71,7 +71,6 @@ typedef enum {
|
|||||||
FMT_GIF, /* GIF format */
|
FMT_GIF, /* GIF format */
|
||||||
FMT_OS2, /* BMP format (OS/2 flavor) */
|
FMT_OS2, /* BMP format (OS/2 flavor) */
|
||||||
FMT_PPM, /* PPM/PGM (PBMPLUS formats) */
|
FMT_PPM, /* PPM/PGM (PBMPLUS formats) */
|
||||||
FMT_RLE, /* RLE format */
|
|
||||||
FMT_TARGA, /* Targa format */
|
FMT_TARGA, /* Targa format */
|
||||||
FMT_TIFF /* TIFF format */
|
FMT_TIFF /* TIFF format */
|
||||||
} IMAGE_FORMATS;
|
} IMAGE_FORMATS;
|
||||||
@@ -141,10 +140,6 @@ usage(void)
|
|||||||
fprintf(stderr, " -pnm Select PBMPLUS (PPM/PGM) output format%s\n",
|
fprintf(stderr, " -pnm Select PBMPLUS (PPM/PGM) output format%s\n",
|
||||||
(DEFAULT_FMT == FMT_PPM ? " (default)" : ""));
|
(DEFAULT_FMT == FMT_PPM ? " (default)" : ""));
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLE_SUPPORTED
|
|
||||||
fprintf(stderr, " -rle Select Utah RLE output format%s\n",
|
|
||||||
(DEFAULT_FMT == FMT_RLE ? " (default)" : ""));
|
|
||||||
#endif
|
|
||||||
#ifdef TARGA_SUPPORTED
|
#ifdef TARGA_SUPPORTED
|
||||||
fprintf(stderr, " -targa Select Targa output format%s\n",
|
fprintf(stderr, " -targa Select Targa output format%s\n",
|
||||||
(DEFAULT_FMT == FMT_TARGA ? " (default)" : ""));
|
(DEFAULT_FMT == FMT_TARGA ? " (default)" : ""));
|
||||||
@@ -400,10 +395,6 @@ parse_switches(j_decompress_ptr cinfo, int argc, char **argv,
|
|||||||
} else if (keymatch(arg, "report", 2)) {
|
} else if (keymatch(arg, "report", 2)) {
|
||||||
report = TRUE;
|
report = TRUE;
|
||||||
|
|
||||||
} else if (keymatch(arg, "rle", 1)) {
|
|
||||||
/* RLE output format. */
|
|
||||||
requested_fmt = FMT_RLE;
|
|
||||||
|
|
||||||
} else if (keymatch(arg, "scale", 2)) {
|
} else if (keymatch(arg, "scale", 2)) {
|
||||||
/* Scale the output image by a fraction M/N. */
|
/* Scale the output image by a fraction M/N. */
|
||||||
if (++argn >= argc) /* advance to next argument */
|
if (++argn >= argc) /* advance to next argument */
|
||||||
@@ -695,11 +686,6 @@ main(int argc, char **argv)
|
|||||||
dest_mgr = jinit_write_ppm(&cinfo);
|
dest_mgr = jinit_write_ppm(&cinfo);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLE_SUPPORTED
|
|
||||||
case FMT_RLE:
|
|
||||||
dest_mgr = jinit_write_rle(&cinfo);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#ifdef TARGA_SUPPORTED
|
#ifdef TARGA_SUPPORTED
|
||||||
case FMT_TARGA:
|
case FMT_TARGA:
|
||||||
dest_mgr = jinit_write_targa(&cinfo);
|
dest_mgr = jinit_write_targa(&cinfo);
|
||||||
|
|||||||
@@ -112,7 +112,6 @@ typedef unsigned char boolean;
|
|||||||
#define BMP_SUPPORTED /* BMP image file format */
|
#define BMP_SUPPORTED /* BMP image file format */
|
||||||
#define GIF_SUPPORTED /* GIF image file format */
|
#define GIF_SUPPORTED /* GIF image file format */
|
||||||
#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
|
#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
|
||||||
#undef RLE_SUPPORTED /* Utah RLE image file format */
|
|
||||||
#define TARGA_SUPPORTED /* Targa image file format */
|
#define TARGA_SUPPORTED /* Targa image file format */
|
||||||
|
|
||||||
/* Define this if you want to name both input and output files on the command
|
/* Define this if you want to name both input and output files on the command
|
||||||
|
|||||||
389
rdrle.c
389
rdrle.c
@@ -1,389 +0,0 @@
|
|||||||
/*
|
|
||||||
* rdrle.c
|
|
||||||
*
|
|
||||||
* This file was part of the Independent JPEG Group's software:
|
|
||||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
|
||||||
* It was modified by The libjpeg-turbo Project to include only code and
|
|
||||||
* information relevant to libjpeg-turbo.
|
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
|
||||||
* file.
|
|
||||||
*
|
|
||||||
* This file contains routines to read input images in Utah RLE format.
|
|
||||||
* The Utah Raster Toolkit library is required (version 3.1 or later).
|
|
||||||
*
|
|
||||||
* These routines may need modification for non-Unix environments or
|
|
||||||
* specialized applications. As they stand, they assume input from
|
|
||||||
* an ordinary stdio stream. They further assume that reading begins
|
|
||||||
* at the start of the file; start_input may need work if the
|
|
||||||
* user interface has already read some data (e.g., to determine that
|
|
||||||
* the file is indeed RLE format).
|
|
||||||
*
|
|
||||||
* Based on code contributed by Mike Lijewski,
|
|
||||||
* with updates from Robert Hutchinson.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
|
||||||
|
|
||||||
#ifdef RLE_SUPPORTED
|
|
||||||
|
|
||||||
/* rle.h is provided by the Utah Raster Toolkit. */
|
|
||||||
|
|
||||||
#include <rle.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We assume that JSAMPLE has the same representation as rle_pixel,
|
|
||||||
* to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if BITS_IN_JSAMPLE != 8
|
|
||||||
Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We support the following types of RLE files:
|
|
||||||
*
|
|
||||||
* GRAYSCALE - 8 bits, no colormap
|
|
||||||
* MAPPEDGRAY - 8 bits, 1 channel colomap
|
|
||||||
* PSEUDOCOLOR - 8 bits, 3 channel colormap
|
|
||||||
* TRUECOLOR - 24 bits, 3 channel colormap
|
|
||||||
* DIRECTCOLOR - 24 bits, no colormap
|
|
||||||
*
|
|
||||||
* For now, we ignore any alpha channel in the image.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{ GRAYSCALE, MAPPEDGRAY, PSEUDOCOLOR, TRUECOLOR, DIRECTCOLOR } rle_kind;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Since RLE stores scanlines bottom-to-top, we have to invert the image
|
|
||||||
* to conform to JPEG's top-to-bottom order. To do this, we read the
|
|
||||||
* incoming image into a virtual array on the first get_pixel_rows call,
|
|
||||||
* then fetch the required row from the virtual array on subsequent calls.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct _rle_source_struct *rle_source_ptr;
|
|
||||||
|
|
||||||
typedef struct _rle_source_struct {
|
|
||||||
struct cjpeg_source_struct pub; /* public fields */
|
|
||||||
|
|
||||||
rle_kind visual; /* actual type of input file */
|
|
||||||
jvirt_sarray_ptr image; /* virtual array to hold the image */
|
|
||||||
JDIMENSION row; /* current row # in the virtual array */
|
|
||||||
rle_hdr header; /* Input file information */
|
|
||||||
rle_pixel **rle_row; /* holds a row returned by rle_getrow() */
|
|
||||||
|
|
||||||
} rle_source_struct;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read the file header; return image size and component count.
|
|
||||||
*/
|
|
||||||
|
|
||||||
METHODDEF(void)
|
|
||||||
start_input_rle(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|
||||||
{
|
|
||||||
rle_source_ptr source = (rle_source_ptr)sinfo;
|
|
||||||
JDIMENSION width, height;
|
|
||||||
#ifdef PROGRESS_REPORT
|
|
||||||
cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Use RLE library routine to get the header info */
|
|
||||||
source->header = *rle_hdr_init(NULL);
|
|
||||||
source->header.rle_file = source->pub.input_file;
|
|
||||||
switch (rle_get_setup(&(source->header))) {
|
|
||||||
case RLE_SUCCESS:
|
|
||||||
/* A-OK */
|
|
||||||
break;
|
|
||||||
case RLE_NOT_RLE:
|
|
||||||
ERREXIT(cinfo, JERR_RLE_NOT);
|
|
||||||
break;
|
|
||||||
case RLE_NO_SPACE:
|
|
||||||
ERREXIT(cinfo, JERR_RLE_MEM);
|
|
||||||
break;
|
|
||||||
case RLE_EMPTY:
|
|
||||||
ERREXIT(cinfo, JERR_RLE_EMPTY);
|
|
||||||
break;
|
|
||||||
case RLE_EOF:
|
|
||||||
ERREXIT(cinfo, JERR_RLE_EOF);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ERREXIT(cinfo, JERR_RLE_BADERROR);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Figure out what we have, set private vars and return values accordingly */
|
|
||||||
|
|
||||||
width = source->header.xmax - source->header.xmin + 1;
|
|
||||||
height = source->header.ymax - source->header.ymin + 1;
|
|
||||||
source->header.xmin = 0; /* realign horizontally */
|
|
||||||
source->header.xmax = width - 1;
|
|
||||||
|
|
||||||
cinfo->image_width = width;
|
|
||||||
cinfo->image_height = height;
|
|
||||||
cinfo->data_precision = 8; /* we can only handle 8 bit data */
|
|
||||||
|
|
||||||
if (source->header.ncolors == 1 && source->header.ncmap == 0) {
|
|
||||||
source->visual = GRAYSCALE;
|
|
||||||
TRACEMS2(cinfo, 1, JTRC_RLE_GRAY, width, height);
|
|
||||||
} else if (source->header.ncolors == 1 && source->header.ncmap == 1) {
|
|
||||||
source->visual = MAPPEDGRAY;
|
|
||||||
TRACEMS3(cinfo, 1, JTRC_RLE_MAPGRAY, width, height,
|
|
||||||
1 << source->header.cmaplen);
|
|
||||||
} else if (source->header.ncolors == 1 && source->header.ncmap == 3) {
|
|
||||||
source->visual = PSEUDOCOLOR;
|
|
||||||
TRACEMS3(cinfo, 1, JTRC_RLE_MAPPED, width, height,
|
|
||||||
1 << source->header.cmaplen);
|
|
||||||
} else if (source->header.ncolors == 3 && source->header.ncmap == 3) {
|
|
||||||
source->visual = TRUECOLOR;
|
|
||||||
TRACEMS3(cinfo, 1, JTRC_RLE_FULLMAP, width, height,
|
|
||||||
1 << source->header.cmaplen);
|
|
||||||
} else if (source->header.ncolors == 3 && source->header.ncmap == 0) {
|
|
||||||
source->visual = DIRECTCOLOR;
|
|
||||||
TRACEMS2(cinfo, 1, JTRC_RLE, width, height);
|
|
||||||
} else
|
|
||||||
ERREXIT(cinfo, JERR_RLE_UNSUPPORTED);
|
|
||||||
|
|
||||||
if (source->visual == GRAYSCALE || source->visual == MAPPEDGRAY) {
|
|
||||||
cinfo->in_color_space = JCS_GRAYSCALE;
|
|
||||||
cinfo->input_components = 1;
|
|
||||||
} else {
|
|
||||||
cinfo->in_color_space = JCS_RGB;
|
|
||||||
cinfo->input_components = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* A place to hold each scanline while it's converted.
|
|
||||||
* (GRAYSCALE scanlines don't need converting)
|
|
||||||
*/
|
|
||||||
if (source->visual != GRAYSCALE) {
|
|
||||||
source->rle_row = (rle_pixel **)(*cinfo->mem->alloc_sarray)
|
|
||||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
|
||||||
(JDIMENSION)width, (JDIMENSION)cinfo->input_components);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* request a virtual array to hold the image */
|
|
||||||
source->image = (*cinfo->mem->request_virt_sarray)
|
|
||||||
((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
|
|
||||||
(JDIMENSION)(width * source->header.ncolors),
|
|
||||||
(JDIMENSION)height, (JDIMENSION)1);
|
|
||||||
|
|
||||||
#ifdef PROGRESS_REPORT
|
|
||||||
if (progress != NULL) {
|
|
||||||
/* count file input as separate pass */
|
|
||||||
progress->total_extra_passes++;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
source->pub.buffer_height = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read one row of pixels.
|
|
||||||
* Called only after load_image has read the image into the virtual array.
|
|
||||||
* Used for GRAYSCALE, MAPPEDGRAY, TRUECOLOR, and DIRECTCOLOR images.
|
|
||||||
*/
|
|
||||||
|
|
||||||
METHODDEF(JDIMENSION)
|
|
||||||
get_rle_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|
||||||
{
|
|
||||||
rle_source_ptr source = (rle_source_ptr)sinfo;
|
|
||||||
|
|
||||||
source->row--;
|
|
||||||
source->pub.buffer = (*cinfo->mem->access_virt_sarray)
|
|
||||||
((j_common_ptr)cinfo, source->image, source->row, (JDIMENSION)1, FALSE);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read one row of pixels.
|
|
||||||
* Called only after load_image has read the image into the virtual array.
|
|
||||||
* Used for PSEUDOCOLOR images.
|
|
||||||
*/
|
|
||||||
|
|
||||||
METHODDEF(JDIMENSION)
|
|
||||||
get_pseudocolor_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|
||||||
{
|
|
||||||
rle_source_ptr source = (rle_source_ptr)sinfo;
|
|
||||||
JSAMPROW src_row, dest_row;
|
|
||||||
JDIMENSION col;
|
|
||||||
rle_map *colormap;
|
|
||||||
int val;
|
|
||||||
|
|
||||||
colormap = source->header.cmap;
|
|
||||||
dest_row = source->pub.buffer[0];
|
|
||||||
source->row--;
|
|
||||||
src_row = *(*cinfo->mem->access_virt_sarray)
|
|
||||||
((j_common_ptr)cinfo, source->image, source->row, (JDIMENSION)1, FALSE);
|
|
||||||
|
|
||||||
for (col = cinfo->image_width; col > 0; col--) {
|
|
||||||
val = *src_row++;
|
|
||||||
*dest_row++ = (JSAMPLE)(colormap[val ] >> 8);
|
|
||||||
*dest_row++ = (JSAMPLE)(colormap[val + 256] >> 8);
|
|
||||||
*dest_row++ = (JSAMPLE)(colormap[val + 512] >> 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Load the image into a virtual array. We have to do this because RLE
|
|
||||||
* files start at the lower left while the JPEG standard has them starting
|
|
||||||
* in the upper left. This is called the first time we want to get a row
|
|
||||||
* of input. What we do is load the RLE data into the array and then call
|
|
||||||
* the appropriate routine to read one row from the array. Before returning,
|
|
||||||
* we set source->pub.get_pixel_rows so that subsequent calls go straight to
|
|
||||||
* the appropriate row-reading routine.
|
|
||||||
*/
|
|
||||||
|
|
||||||
METHODDEF(JDIMENSION)
|
|
||||||
load_image(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|
||||||
{
|
|
||||||
rle_source_ptr source = (rle_source_ptr)sinfo;
|
|
||||||
JDIMENSION row, col;
|
|
||||||
JSAMPROW scanline, red_ptr, green_ptr, blue_ptr;
|
|
||||||
rle_pixel **rle_row;
|
|
||||||
rle_map *colormap;
|
|
||||||
char channel;
|
|
||||||
#ifdef PROGRESS_REPORT
|
|
||||||
cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
colormap = source->header.cmap;
|
|
||||||
rle_row = source->rle_row;
|
|
||||||
|
|
||||||
/* Read the RLE data into our virtual array.
|
|
||||||
* We assume here that rle_pixel is represented the same as JSAMPLE.
|
|
||||||
*/
|
|
||||||
RLE_CLR_BIT(source->header, RLE_ALPHA); /* don't read the alpha channel */
|
|
||||||
|
|
||||||
#ifdef PROGRESS_REPORT
|
|
||||||
if (progress != NULL) {
|
|
||||||
progress->pub.pass_limit = cinfo->image_height;
|
|
||||||
progress->pub.pass_counter = 0;
|
|
||||||
(*progress->pub.progress_monitor) ((j_common_ptr)cinfo);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (source->visual) {
|
|
||||||
|
|
||||||
case GRAYSCALE:
|
|
||||||
case PSEUDOCOLOR:
|
|
||||||
for (row = 0; row < cinfo->image_height; row++) {
|
|
||||||
rle_row = (rle_pixel **)(*cinfo->mem->access_virt_sarray)
|
|
||||||
((j_common_ptr)cinfo, source->image, row, (JDIMENSION)1, TRUE);
|
|
||||||
rle_getrow(&source->header, rle_row);
|
|
||||||
#ifdef PROGRESS_REPORT
|
|
||||||
if (progress != NULL) {
|
|
||||||
progress->pub.pass_counter++;
|
|
||||||
(*progress->pub.progress_monitor) ((j_common_ptr)cinfo);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MAPPEDGRAY:
|
|
||||||
case TRUECOLOR:
|
|
||||||
for (row = 0; row < cinfo->image_height; row++) {
|
|
||||||
scanline = *(*cinfo->mem->access_virt_sarray)
|
|
||||||
((j_common_ptr)cinfo, source->image, row, (JDIMENSION)1, TRUE);
|
|
||||||
rle_row = source->rle_row;
|
|
||||||
rle_getrow(&source->header, rle_row);
|
|
||||||
|
|
||||||
for (col = 0; col < cinfo->image_width; col++) {
|
|
||||||
for (channel = 0; channel < source->header.ncolors; channel++) {
|
|
||||||
*scanline++ =
|
|
||||||
(JSAMPLE)(colormap[rle_row[channel][col] + 256 * channel] >> 8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef PROGRESS_REPORT
|
|
||||||
if (progress != NULL) {
|
|
||||||
progress->pub.pass_counter++;
|
|
||||||
(*progress->pub.progress_monitor) ((j_common_ptr)cinfo);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DIRECTCOLOR:
|
|
||||||
for (row = 0; row < cinfo->image_height; row++) {
|
|
||||||
scanline = *(*cinfo->mem->access_virt_sarray)
|
|
||||||
((j_common_ptr)cinfo, source->image, row, (JDIMENSION)1, TRUE);
|
|
||||||
rle_getrow(&source->header, rle_row);
|
|
||||||
|
|
||||||
red_ptr = rle_row[0];
|
|
||||||
green_ptr = rle_row[1];
|
|
||||||
blue_ptr = rle_row[2];
|
|
||||||
|
|
||||||
for (col = cinfo->image_width; col > 0; col--) {
|
|
||||||
*scanline++ = *red_ptr++;
|
|
||||||
*scanline++ = *green_ptr++;
|
|
||||||
*scanline++ = *blue_ptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef PROGRESS_REPORT
|
|
||||||
if (progress != NULL) {
|
|
||||||
progress->pub.pass_counter++;
|
|
||||||
(*progress->pub.progress_monitor) ((j_common_ptr)cinfo);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef PROGRESS_REPORT
|
|
||||||
if (progress != NULL)
|
|
||||||
progress->completed_extra_passes++;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set up to call proper row-extraction routine in future */
|
|
||||||
if (source->visual == PSEUDOCOLOR) {
|
|
||||||
source->pub.buffer = source->rle_row;
|
|
||||||
source->pub.get_pixel_rows = get_pseudocolor_row;
|
|
||||||
} else {
|
|
||||||
source->pub.get_pixel_rows = get_rle_row;
|
|
||||||
}
|
|
||||||
source->row = cinfo->image_height;
|
|
||||||
|
|
||||||
/* And fetch the topmost (bottommost) row */
|
|
||||||
return (*source->pub.get_pixel_rows) (cinfo, sinfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Finish up at the end of the file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
METHODDEF(void)
|
|
||||||
finish_input_rle(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|
||||||
{
|
|
||||||
/* no work */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The module selection routine for RLE format input.
|
|
||||||
*/
|
|
||||||
|
|
||||||
GLOBAL(cjpeg_source_ptr)
|
|
||||||
jinit_read_rle(j_compress_ptr cinfo)
|
|
||||||
{
|
|
||||||
rle_source_ptr source;
|
|
||||||
|
|
||||||
/* Create module interface object */
|
|
||||||
source = (rle_source_ptr)
|
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
|
||||||
sizeof(rle_source_struct));
|
|
||||||
/* Fill in method ptrs */
|
|
||||||
source->pub.start_input = start_input_rle;
|
|
||||||
source->pub.finish_input = finish_input_rle;
|
|
||||||
source->pub.get_pixel_rows = load_image;
|
|
||||||
|
|
||||||
return (cjpeg_source_ptr)source;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* RLE_SUPPORTED */
|
|
||||||
10
usage.txt
10
usage.txt
@@ -50,11 +50,9 @@ or
|
|||||||
This syntax works on all systems, so it is useful for scripts.
|
This syntax works on all systems, so it is useful for scripts.
|
||||||
|
|
||||||
The currently supported image file formats are: PPM (PBMPLUS color format),
|
The currently supported image file formats are: PPM (PBMPLUS color format),
|
||||||
PGM (PBMPLUS grayscale format), BMP, Targa, and RLE (Utah Raster Toolkit
|
PGM (PBMPLUS grayscale format), BMP, and Targa. cjpeg recognizes the input
|
||||||
format). (RLE is supported only if the URT library is available, which it
|
image format automatically, with the exception of some Targa files. You have
|
||||||
isn't on most non-Unix systems.) cjpeg recognizes the input image format
|
to tell djpeg which format to generate.
|
||||||
automatically, with the exception of some Targa files. You have to tell djpeg
|
|
||||||
which format to generate.
|
|
||||||
|
|
||||||
JPEG files are in the defacto standard JFIF file format. There are other,
|
JPEG files are in the defacto standard JFIF file format. There are other,
|
||||||
less widely used JPEG-based file formats, but we don't support them.
|
less widely used JPEG-based file formats, but we don't support them.
|
||||||
@@ -305,8 +303,6 @@ The basic command line switches for djpeg are:
|
|||||||
grayscale or if -grayscale is specified; otherwise
|
grayscale or if -grayscale is specified; otherwise
|
||||||
PPM is emitted.
|
PPM is emitted.
|
||||||
|
|
||||||
-rle Select RLE output format. (Requires URT library.)
|
|
||||||
|
|
||||||
-targa Select Targa output format. Grayscale format is
|
-targa Select Targa output format. Grayscale format is
|
||||||
emitted if the JPEG file is grayscale or if
|
emitted if the JPEG file is grayscale or if
|
||||||
-grayscale is specified; otherwise, colormapped format
|
-grayscale is specified; otherwise, colormapped format
|
||||||
|
|||||||
308
wrrle.c
308
wrrle.c
@@ -1,308 +0,0 @@
|
|||||||
/*
|
|
||||||
* wrrle.c
|
|
||||||
*
|
|
||||||
* This file was part of the Independent JPEG Group's software:
|
|
||||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
|
||||||
* libjpeg-turbo Modifications:
|
|
||||||
* Copyright (C) 2017, D. R. Commander.
|
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
|
||||||
* file.
|
|
||||||
*
|
|
||||||
* This file contains routines to write output images in RLE format.
|
|
||||||
* The Utah Raster Toolkit library is required (version 3.1 or later).
|
|
||||||
*
|
|
||||||
* These routines may need modification for non-Unix environments or
|
|
||||||
* specialized applications. As they stand, they assume output to
|
|
||||||
* an ordinary stdio stream.
|
|
||||||
*
|
|
||||||
* Based on code contributed by Mike Lijewski,
|
|
||||||
* with updates from Robert Hutchinson.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
|
||||||
|
|
||||||
#ifdef RLE_SUPPORTED
|
|
||||||
|
|
||||||
/* rle.h is provided by the Utah Raster Toolkit. */
|
|
||||||
|
|
||||||
#include <rle.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We assume that JSAMPLE has the same representation as rle_pixel,
|
|
||||||
* to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if BITS_IN_JSAMPLE != 8
|
|
||||||
Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Since RLE stores scanlines bottom-to-top, we have to invert the image
|
|
||||||
* from JPEG's top-to-bottom order. To do this, we save the outgoing data
|
|
||||||
* in a virtual array during put_pixel_row calls, then actually emit the
|
|
||||||
* RLE file during finish_output.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For now, if we emit an RLE color map then it is always 256 entries long,
|
|
||||||
* though not all of the entries need be used.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define CMAPBITS 8
|
|
||||||
#define CMAPLENGTH (1 << (CMAPBITS))
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
struct djpeg_dest_struct pub; /* public fields */
|
|
||||||
|
|
||||||
jvirt_sarray_ptr image; /* virtual array to store the output image */
|
|
||||||
rle_map *colormap; /* RLE-style color map, or NULL if none */
|
|
||||||
rle_pixel **rle_row; /* To pass rows to rle_putrow() */
|
|
||||||
|
|
||||||
} rle_dest_struct;
|
|
||||||
|
|
||||||
typedef rle_dest_struct *rle_dest_ptr;
|
|
||||||
|
|
||||||
/* Forward declarations */
|
|
||||||
METHODDEF(void) rle_put_pixel_rows(j_decompress_ptr cinfo,
|
|
||||||
djpeg_dest_ptr dinfo,
|
|
||||||
JDIMENSION rows_supplied);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write the file header.
|
|
||||||
*
|
|
||||||
* In this module it's easier to wait till finish_output to write anything.
|
|
||||||
*/
|
|
||||||
|
|
||||||
METHODDEF(void)
|
|
||||||
start_output_rle(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
|
|
||||||
{
|
|
||||||
rle_dest_ptr dest = (rle_dest_ptr)dinfo;
|
|
||||||
size_t cmapsize;
|
|
||||||
int i, ci;
|
|
||||||
#ifdef PROGRESS_REPORT
|
|
||||||
cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Make sure the image can be stored in RLE format.
|
|
||||||
*
|
|
||||||
* - RLE stores image dimensions as *signed* 16 bit integers. JPEG
|
|
||||||
* uses unsigned, so we have to check the width.
|
|
||||||
*
|
|
||||||
* - Colorspace is expected to be grayscale or RGB.
|
|
||||||
*
|
|
||||||
* - The number of channels (components) is expected to be 1 (grayscale/
|
|
||||||
* pseudocolor) or 3 (truecolor/directcolor).
|
|
||||||
* (could be 2 or 4 if using an alpha channel, but we aren't)
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (cinfo->output_width > 32767 || cinfo->output_height > 32767)
|
|
||||||
ERREXIT2(cinfo, JERR_RLE_DIMENSIONS, cinfo->output_width,
|
|
||||||
cinfo->output_height);
|
|
||||||
|
|
||||||
if (cinfo->out_color_space != JCS_GRAYSCALE &&
|
|
||||||
cinfo->out_color_space != JCS_RGB)
|
|
||||||
ERREXIT(cinfo, JERR_RLE_COLORSPACE);
|
|
||||||
|
|
||||||
if (cinfo->output_components != 1 && cinfo->output_components != 3)
|
|
||||||
ERREXIT1(cinfo, JERR_RLE_TOOMANYCHANNELS, cinfo->num_components);
|
|
||||||
|
|
||||||
/* Convert colormap, if any, to RLE format. */
|
|
||||||
|
|
||||||
dest->colormap = NULL;
|
|
||||||
|
|
||||||
if (cinfo->quantize_colors) {
|
|
||||||
/* Allocate storage for RLE-style cmap, zero any extra entries */
|
|
||||||
cmapsize = cinfo->out_color_components * CMAPLENGTH * sizeof(rle_map);
|
|
||||||
dest->colormap = (rle_map *)(*cinfo->mem->alloc_small)
|
|
||||||
((j_common_ptr)cinfo, JPOOL_IMAGE, cmapsize);
|
|
||||||
MEMZERO(dest->colormap, cmapsize);
|
|
||||||
|
|
||||||
/* Save away data in RLE format --- note 8-bit left shift! */
|
|
||||||
/* Shifting would need adjustment for JSAMPLEs wider than 8 bits. */
|
|
||||||
for (ci = 0; ci < cinfo->out_color_components; ci++) {
|
|
||||||
for (i = 0; i < cinfo->actual_number_of_colors; i++) {
|
|
||||||
dest->colormap[ci * CMAPLENGTH + i] = cinfo->colormap[ci][i] << 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the output buffer to the first row */
|
|
||||||
dest->pub.buffer = (*cinfo->mem->access_virt_sarray)
|
|
||||||
((j_common_ptr)cinfo, dest->image, (JDIMENSION)0, (JDIMENSION)1, TRUE);
|
|
||||||
dest->pub.buffer_height = 1;
|
|
||||||
|
|
||||||
dest->pub.put_pixel_rows = rle_put_pixel_rows;
|
|
||||||
|
|
||||||
#ifdef PROGRESS_REPORT
|
|
||||||
if (progress != NULL) {
|
|
||||||
progress->total_extra_passes++; /* count file writing as separate pass */
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write some pixel data.
|
|
||||||
*
|
|
||||||
* This routine just saves the data away in a virtual array.
|
|
||||||
*/
|
|
||||||
|
|
||||||
METHODDEF(void)
|
|
||||||
rle_put_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
|
|
||||||
JDIMENSION rows_supplied)
|
|
||||||
{
|
|
||||||
rle_dest_ptr dest = (rle_dest_ptr)dinfo;
|
|
||||||
|
|
||||||
if (cinfo->output_scanline < cinfo->output_height) {
|
|
||||||
dest->pub.buffer = (*cinfo->mem->access_virt_sarray)
|
|
||||||
((j_common_ptr)cinfo, dest->image,
|
|
||||||
cinfo->output_scanline, (JDIMENSION)1, TRUE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Finish up at the end of the file.
|
|
||||||
*
|
|
||||||
* Here is where we really output the RLE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
METHODDEF(void)
|
|
||||||
finish_output_rle(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
|
|
||||||
{
|
|
||||||
rle_dest_ptr dest = (rle_dest_ptr)dinfo;
|
|
||||||
rle_hdr header; /* Output file information */
|
|
||||||
rle_pixel **rle_row, *red, *green, *blue;
|
|
||||||
JSAMPROW output_row;
|
|
||||||
char cmapcomment[80];
|
|
||||||
int row, col;
|
|
||||||
int ci;
|
|
||||||
#ifdef PROGRESS_REPORT
|
|
||||||
cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Initialize the header info */
|
|
||||||
header = *rle_hdr_init(NULL);
|
|
||||||
header.rle_file = dest->pub.output_file;
|
|
||||||
header.xmin = 0;
|
|
||||||
header.xmax = cinfo->output_width - 1;
|
|
||||||
header.ymin = 0;
|
|
||||||
header.ymax = cinfo->output_height - 1;
|
|
||||||
header.alpha = 0;
|
|
||||||
header.ncolors = cinfo->output_components;
|
|
||||||
for (ci = 0; ci < cinfo->output_components; ci++) {
|
|
||||||
RLE_SET_BIT(header, ci);
|
|
||||||
}
|
|
||||||
if (cinfo->quantize_colors) {
|
|
||||||
header.ncmap = cinfo->out_color_components;
|
|
||||||
header.cmaplen = CMAPBITS;
|
|
||||||
header.cmap = dest->colormap;
|
|
||||||
/* Add a comment to the output image with the true colormap length. */
|
|
||||||
sprintf(cmapcomment, "color_map_length=%d",
|
|
||||||
cinfo->actual_number_of_colors);
|
|
||||||
rle_putcom(cmapcomment, &header);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Emit the RLE header and color map (if any) */
|
|
||||||
rle_put_setup(&header);
|
|
||||||
|
|
||||||
/* Now output the RLE data from our virtual array.
|
|
||||||
* We assume here that rle_pixel is represented the same as JSAMPLE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef PROGRESS_REPORT
|
|
||||||
if (progress != NULL) {
|
|
||||||
progress->pub.pass_limit = cinfo->output_height;
|
|
||||||
progress->pub.pass_counter = 0;
|
|
||||||
(*progress->pub.progress_monitor) ((j_common_ptr)cinfo);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (cinfo->output_components == 1) {
|
|
||||||
for (row = cinfo->output_height - 1; row >= 0; row--) {
|
|
||||||
rle_row = (rle_pixel **)(*cinfo->mem->access_virt_sarray)
|
|
||||||
((j_common_ptr)cinfo, dest->image,
|
|
||||||
(JDIMENSION)row, (JDIMENSION)1, FALSE);
|
|
||||||
rle_putrow(rle_row, (int)cinfo->output_width, &header);
|
|
||||||
#ifdef PROGRESS_REPORT
|
|
||||||
if (progress != NULL) {
|
|
||||||
progress->pub.pass_counter++;
|
|
||||||
(*progress->pub.progress_monitor) ((j_common_ptr)cinfo);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (row = cinfo->output_height - 1; row >= 0; row--) {
|
|
||||||
rle_row = (rle_pixel **)dest->rle_row;
|
|
||||||
output_row = *(*cinfo->mem->access_virt_sarray)
|
|
||||||
((j_common_ptr)cinfo, dest->image,
|
|
||||||
(JDIMENSION)row, (JDIMENSION)1, FALSE);
|
|
||||||
red = rle_row[0];
|
|
||||||
green = rle_row[1];
|
|
||||||
blue = rle_row[2];
|
|
||||||
for (col = cinfo->output_width; col > 0; col--) {
|
|
||||||
*red++ = *output_row++;
|
|
||||||
*green++ = *output_row++;
|
|
||||||
*blue++ = *output_row++;
|
|
||||||
}
|
|
||||||
rle_putrow(rle_row, (int)cinfo->output_width, &header);
|
|
||||||
#ifdef PROGRESS_REPORT
|
|
||||||
if (progress != NULL) {
|
|
||||||
progress->pub.pass_counter++;
|
|
||||||
(*progress->pub.progress_monitor) ((j_common_ptr)cinfo);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef PROGRESS_REPORT
|
|
||||||
if (progress != NULL)
|
|
||||||
progress->completed_extra_passes++;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Emit file trailer */
|
|
||||||
rle_puteof(&header);
|
|
||||||
fflush(dest->pub.output_file);
|
|
||||||
if (ferror(dest->pub.output_file))
|
|
||||||
ERREXIT(cinfo, JERR_FILE_WRITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The module selection routine for RLE format output.
|
|
||||||
*/
|
|
||||||
|
|
||||||
GLOBAL(djpeg_dest_ptr)
|
|
||||||
jinit_write_rle(j_decompress_ptr cinfo)
|
|
||||||
{
|
|
||||||
rle_dest_ptr dest;
|
|
||||||
|
|
||||||
/* Create module interface object, fill in method pointers */
|
|
||||||
dest = (rle_dest_ptr)
|
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
|
||||||
sizeof(rle_dest_struct));
|
|
||||||
dest->pub.start_output = start_output_rle;
|
|
||||||
dest->pub.finish_output = finish_output_rle;
|
|
||||||
dest->pub.calc_buffer_dimensions = NULL;
|
|
||||||
|
|
||||||
/* Calculate output image dimensions so we can allocate space */
|
|
||||||
jpeg_calc_output_dimensions(cinfo);
|
|
||||||
|
|
||||||
/* Allocate a work array for output to the RLE library. */
|
|
||||||
dest->rle_row = (*cinfo->mem->alloc_sarray)
|
|
||||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
|
||||||
cinfo->output_width, (JDIMENSION)cinfo->output_components);
|
|
||||||
|
|
||||||
/* Allocate a virtual array to hold the image. */
|
|
||||||
dest->image = (*cinfo->mem->request_virt_sarray)
|
|
||||||
((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
|
|
||||||
(JDIMENSION)(cinfo->output_width * cinfo->output_components),
|
|
||||||
cinfo->output_height, (JDIMENSION)1);
|
|
||||||
|
|
||||||
return (djpeg_dest_ptr)dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* RLE_SUPPORTED */
|
|
||||||
Reference in New Issue
Block a user