45#define JMESSAGE(code,string) string ,
72#define DEFAULT_FMT FMT_PPM
96#ifdef TWO_FILE_COMMANDLINE
103 fprintf(
stderr,
" -colors N Reduce image to no more than N colors\n");
107#ifdef IDCT_SCALING_SUPPORTED
108 fprintf(
stderr,
" -scale M/N Scale output image by fraction M/N, eg, 1/8\n");
111 fprintf(
stderr,
" -bmp Select BMP output format (Windows style)%s\n",
115 fprintf(
stderr,
" -gif Select GIF output format (LZW compressed)%s\n",
117 fprintf(
stderr,
" -gif0 Select GIF output format (uncompressed)%s\n",
121 fprintf(
stderr,
" -os2 Select BMP output format (OS/2 style)%s\n",
125 fprintf(
stderr,
" -pnm Select PBMPLUS (PPM/PGM) output format%s\n",
132#ifdef TARGA_SUPPORTED
137#ifdef DCT_ISLOW_SUPPORTED
141#ifdef DCT_IFAST_SUPPORTED
142 fprintf(
stderr,
" -dct fast Use fast integer DCT (less accurate)%s\n",
145#ifdef DCT_FLOAT_SUPPORTED
146 fprintf(
stderr,
" -dct float Use floating-point DCT method%s\n",
149 fprintf(
stderr,
" -dither fs Use F-S dithering (default)\n");
150 fprintf(
stderr,
" -dither none Don't use dithering in quantization\n");
151 fprintf(
stderr,
" -dither ordered Use ordered dither (medium speed, quality)\n");
152#ifdef QUANT_2PASS_SUPPORTED
153 fprintf(
stderr,
" -map FILE Map to colors used in named image file\n");
155 fprintf(
stderr,
" -nosmooth Don't use high-quality upsampling\n");
156#ifdef QUANT_1PASS_SUPPORTED
157 fprintf(
stderr,
" -onepass Use 1-pass quantization (fast, low quality)\n");
159 fprintf(
stderr,
" -maxmemory N Maximum memory to use (in kbytes)\n");
160 fprintf(
stderr,
" -outfile name Specify name for output file\n");
168 int last_file_arg_seen,
boolean for_real)
184 cinfo->err->trace_level = 0;
188 for (argn = 1; argn <
argc; argn++) {
192 if (argn <= last_file_arg_seen) {
213 cinfo->desired_number_of_colors =
val;
214 cinfo->quantize_colors =
TRUE;
245 static boolean printed_version =
FALSE;
247 if (! printed_version) {
248 fprintf(
stderr,
"Independent JPEG Group's DJPEG, version %s\n%s\n",
250 printed_version =
TRUE;
252 cinfo->err->trace_level++;
256 cinfo->two_pass_quantize =
FALSE;
258 if (! cinfo->quantize_colors)
259 cinfo->desired_number_of_colors = 216;
261 cinfo->do_fancy_upsampling =
FALSE;
277 cinfo->out_color_space =
JCS_RGB;
284#ifdef QUANT_2PASS_SUPPORTED
291 read_color_map(cinfo, mapfile);
293 cinfo->quantize_colors =
TRUE;
295 ERREXIT(cinfo, JERR_NOT_COMPILED);
306 if (
sscanf(
argv[argn],
"%ld%c", &lval, &ch) < 1)
308 if (ch ==
'm' || ch ==
'M')
310 cinfo->mem->max_memory_to_use = lval * 1000L;
314 cinfo->do_fancy_upsampling =
FALSE;
318 cinfo->two_pass_quantize =
FALSE;
343 &cinfo->scale_num, &cinfo->scale_denom) < 1)
373 if (! (*datasrc->fill_input_buffer) (cinfo))
374 ERREXIT(cinfo, JERR_CANT_SUSPEND);
384 boolean traceit = (cinfo->err->trace_level >= 1);
387 unsigned int lastch = 0;
394 if (cinfo->unread_marker ==
JPEG_COM)
411 }
else if (ch ==
'\n') {
414 }
else if (ch ==
'\\') {
441#ifdef PROGRESS_REPORT
477#ifdef NEED_SIGNAL_CATCHER
491#ifdef TWO_FILE_COMMANDLINE
494 if (file_index !=
argc-2) {
495 fprintf(
stderr,
"%s: must name one input and one output file\n",
501 if (file_index !=
argc-1) {
502 fprintf(
stderr,
"%s: must name one input and one output file\n",
509 if (file_index <
argc-1) {
516 if (file_index <
argc) {
537#ifdef PROGRESS_REPORT
556 dest_mgr = jinit_write_bmp(&cinfo,
FALSE);
559 dest_mgr = jinit_write_bmp(&cinfo,
TRUE);
564 dest_mgr = jinit_write_gif(&cinfo,
TRUE);
567 dest_mgr = jinit_write_gif(&cinfo,
FALSE);
572 dest_mgr = jinit_write_ppm(&cinfo);
577 dest_mgr = jinit_write_rle(&cinfo);
580#ifdef TARGA_SUPPORTED
582 dest_mgr = jinit_write_targa(&cinfo);
586 ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT);
591 (
void) jpeg_start_decompress(&cinfo);
594 (*dest_mgr->start_output) (&cinfo, dest_mgr);
600 (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
603#ifdef PROGRESS_REPORT
614 (*dest_mgr->finish_output) (&cinfo, dest_mgr);
619 if (input_file !=
stdin)
621 if (output_file !=
stdout)
624#ifdef PROGRESS_REPORT
keymatch(char *arg, const char *keyword, int minchars)
static IMAGE_FORMATS requested_fmt
static const char *const cdjpeg_message_table[]
print_text_marker(j_decompress_ptr cinfo)
static char * outfilename
static const char * progname
jpeg_getc(j_decompress_ptr cinfo)
parse_switches(j_decompress_ptr cinfo, int argc, char **argv, int last_file_arg_seen, boolean for_real)
GLuint GLsizei GLsizei * length
GLsizeiptr const GLvoid GLenum usage
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl putc(_In_ int _Ch, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
jpeg_destroy_decompress(j_decompress_ptr cinfo)
jpeg_finish_decompress(j_decompress_ptr cinfo)
jpeg_read_header(j_decompress_ptr cinfo, boolean require_image)
jpeg_read_scanlines(j_decompress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION max_lines)
jpeg_stdio_src(j_decompress_ptr cinfo, FILE *infile)
jpeg_set_marker_processor(j_decompress_ptr cinfo, int marker_code, jpeg_marker_parser_method routine)
jpeg_std_error(struct jpeg_error_mgr *err)
#define jpeg_create_decompress(cinfo)
struct jpeg_progress_mgr pub
JDIMENSION output_scanline
const char *const * addon_message_table
const JOCTET * next_input_byte