44 #define JMESSAGE(code,string) string , 46 static const char *
const cdjpeg_message_table[] = {
70 #define DEFAULT_FMT FMT_PPM 85 static const char * progname;
86 static char * outfilename;
93 fprintf(stderr,
"usage: %s [switches] ", progname);
94 #ifdef TWO_FILE_COMMANDLINE 95 fprintf(stderr,
"inputfile outputfile\n");
97 fprintf(stderr,
"[inputfile]\n");
100 fprintf(stderr,
"Switches (names may be abbreviated):\n");
101 fprintf(stderr,
" -colors N Reduce image to no more than N colors\n");
102 fprintf(stderr,
" -fast Fast, low-quality processing\n");
103 fprintf(stderr,
" -grayscale Force grayscale output\n");
104 #ifdef IDCT_SCALING_SUPPORTED 105 fprintf(stderr,
" -scale M/N Scale output image by fraction M/N, eg, 1/8\n");
108 fprintf(stderr,
" -bmp Select BMP output format (Windows style)%s\n",
112 fprintf(stderr,
" -gif Select GIF output format%s\n",
116 fprintf(stderr,
" -os2 Select BMP output format (OS/2 style)%s\n",
120 fprintf(stderr,
" -pnm Select PBMPLUS (PPM/PGM) output format%s\n",
124 fprintf(stderr,
" -rle Select Utah RLE output format%s\n",
127 #ifdef TARGA_SUPPORTED 128 fprintf(stderr,
" -targa Select Targa output format%s\n",
131 fprintf(stderr,
"Switches for advanced users:\n");
132 #ifdef DCT_ISLOW_SUPPORTED 133 fprintf(stderr,
" -dct int Use integer DCT method%s\n",
136 #ifdef DCT_IFAST_SUPPORTED 137 fprintf(stderr,
" -dct fast Use fast integer DCT (less accurate)%s\n",
140 #ifdef DCT_FLOAT_SUPPORTED 141 fprintf(stderr,
" -dct float Use floating-point DCT method%s\n",
144 fprintf(stderr,
" -dither fs Use F-S dithering (default)\n");
145 fprintf(stderr,
" -dither none Don't use dithering in quantization\n");
146 fprintf(stderr,
" -dither ordered Use ordered dither (medium speed, quality)\n");
147 #ifdef QUANT_2PASS_SUPPORTED 148 fprintf(stderr,
" -map FILE Map to colors used in named image file\n");
150 fprintf(stderr,
" -nosmooth Don't use high-quality upsampling\n");
151 #ifdef QUANT_1PASS_SUPPORTED 152 fprintf(stderr,
" -onepass Use 1-pass quantization (fast, low quality)\n");
154 fprintf(stderr,
" -maxmemory N Maximum memory to use (in kbytes)\n");
155 fprintf(stderr,
" -outfile name Specify name for output file\n");
156 fprintf(stderr,
" -verbose or -debug Emit debug output\n");
163 int last_file_arg_seen,
boolean for_real)
179 cinfo->err->trace_level = 0;
183 for (argn = 1; argn < argc; argn++) {
187 if (argn <= last_file_arg_seen) {
206 if (sscanf(argv[argn],
"%d", &val) != 1)
208 cinfo->desired_number_of_colors =
val;
209 cinfo->quantize_colors =
TRUE;
215 if (
keymatch(argv[argn],
"int", 1)) {
217 }
else if (
keymatch(argv[argn],
"fast", 2)) {
219 }
else if (
keymatch(argv[argn],
"float", 2)) {
228 if (
keymatch(argv[argn],
"fs", 2)) {
230 }
else if (
keymatch(argv[argn],
"none", 2)) {
232 }
else if (
keymatch(argv[argn],
"ordered", 2)) {
240 static boolean printed_version =
FALSE;
242 if (! printed_version) {
243 fprintf(stderr,
"Independent JPEG Group's DJPEG, version %s\n%s\n",
245 printed_version =
TRUE;
247 cinfo->err->trace_level++;
251 cinfo->two_pass_quantize =
FALSE;
253 if (! cinfo->quantize_colors)
254 cinfo->desired_number_of_colors = 216;
256 cinfo->do_fancy_upsampling =
FALSE;
271 #ifdef QUANT_2PASS_SUPPORTED 275 fprintf(stderr,
"%s: can't open %s\n", progname, argv[argn]);
280 cinfo->quantize_colors =
TRUE;
282 ERREXIT(cinfo, JERR_NOT_COMPILED);
293 if (sscanf(argv[argn],
"%ld%c", &lval, &ch) < 1)
295 if (ch ==
'm' || ch ==
'M')
297 cinfo->mem->max_memory_to_use = lval * 1000L;
301 cinfo->do_fancy_upsampling =
FALSE;
305 cinfo->two_pass_quantize =
FALSE;
315 outfilename = argv[argn];
329 if (sscanf(argv[argn],
"%d/%d",
330 &cinfo->scale_num, &cinfo->scale_denom) != 2)
360 if (! (*datasrc->fill_input_buffer) (cinfo))
361 ERREXIT(cinfo, JERR_CANT_SUSPEND);
371 boolean traceit = (cinfo->err->trace_level >= 1);
374 unsigned int lastch = 0;
381 if (cinfo->unread_marker ==
JPEG_COM)
382 fprintf(stderr,
"Comment, length %ld:\n", (
long)
length);
384 fprintf(stderr,
"APP%d, length %ld:\n",
385 cinfo->unread_marker -
JPEG_APP0, (
long) length);
397 fprintf(stderr,
"\n");
398 }
else if (ch ==
'\n') {
400 fprintf(stderr,
"\n");
401 }
else if (ch ==
'\\') {
402 fprintf(stderr,
"\\\\");
403 }
else if (isprint(ch)) {
406 fprintf(stderr,
"\\%03o", ch);
413 fprintf(stderr,
"\n");
428 #ifdef PROGRESS_REPORT 439 argc = ccommand(&argv);
443 if (progname ==
NULL || progname[0] == 0)
464 #ifdef NEED_SIGNAL_CATCHER 478 #ifdef TWO_FILE_COMMANDLINE 480 if (outfilename ==
NULL) {
481 if (file_index != argc-2) {
482 fprintf(stderr,
"%s: must name one input and one output file\n",
486 outfilename = argv[file_index+1];
488 if (file_index != argc-1) {
489 fprintf(stderr,
"%s: must name one input and one output file\n",
496 if (file_index < argc-1) {
497 fprintf(stderr,
"%s: only one input file\n", progname);
503 if (file_index < argc) {
505 fprintf(stderr,
"%s: can't open %s\n", progname, argv[file_index]);
514 if (outfilename !=
NULL) {
516 fprintf(stderr,
"%s: can't open %s\n", progname, outfilename);
524 #ifdef PROGRESS_REPORT 525 start_progress_monitor((
j_common_ptr) &cinfo, &progress);
540 switch (requested_fmt) {
561 dest_mgr = jinit_write_rle(&cinfo);
564 #ifdef TARGA_SUPPORTED 570 ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT);
576 (
void) jpeg_start_decompress(&cinfo);
579 (*dest_mgr->start_output) (&cinfo, dest_mgr);
582 while (cinfo.output_scanline < cinfo.output_height) {
585 (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
588 #ifdef PROGRESS_REPORT 599 (*dest_mgr->finish_output) (&cinfo, dest_mgr);
604 if (input_file != stdin)
606 if (output_file != stdout)
609 #ifdef PROGRESS_REPORT GLenum GLuint GLenum GLsizei length
jpeg_read_header(j_decompress_ptr cinfo, boolean require_image)
print_text_marker(j_decompress_ptr cinfo)
int main(int argc, char **argv)
const char *const * addon_message_table
#define ERREXIT(cinfo, code)
read_color_map(j_decompress_ptr cinfo, FILE *infile)
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
#define jpeg_create_decompress(cinfo)
jinit_write_gif(j_decompress_ptr cinfo)
GLsizeiptr const GLvoid GLenum usage
keymatch(char *arg, const char *keyword, int minchars)
jinit_write_ppm(j_decompress_ptr cinfo)
jpeg_stdio_src(j_decompress_ptr cinfo, FILE *infile)
parse_switches(j_decompress_ptr cinfo, int argc, char **argv, int last_file_arg_seen, boolean for_real)
struct jpeg_progress_mgr pub
jpeg_getc(j_decompress_ptr cinfo)
jpeg_finish_decompress(j_decompress_ptr cinfo)
jpeg_set_marker_processor(j_decompress_ptr cinfo, int marker_code, jpeg_marker_parser_method routine)
jpeg_destroy_decompress(j_decompress_ptr cinfo)
jpeg_read_scanlines(j_decompress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION max_lines)
jinit_write_bmp(j_decompress_ptr cinfo, boolean is_os2)
jpeg_std_error(struct jpeg_error_mgr *err)
const JOCTET * next_input_byte
jinit_write_targa(j_decompress_ptr cinfo)