2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: cdjpeg.h /main/2 1996/05/09 03:45:31 drk $ */
27 * Copyright (C) 1994-1996, Thomas G. Lane.
28 * This file is part of the Independent JPEG Group's software.
29 * For conditions of distribution and use, see the accompanying README file.
31 * This file contains common declarations for the sample applications
32 * cjpeg and djpeg. It is NOT used by the core JPEG library.
35 #define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */
36 #define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */
39 #include "jerror.h" /* get library error codes too */
40 #include "cderror.h" /* get application-specific error codes */
44 * Object interface for cjpeg's source file decoding modules
47 typedef struct cjpeg_source_struct * cjpeg_source_ptr;
49 struct cjpeg_source_struct {
50 JMETHOD(void, start_input, (j_compress_ptr cinfo,
51 cjpeg_source_ptr sinfo));
52 JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo,
53 cjpeg_source_ptr sinfo));
54 JMETHOD(void, finish_input, (j_compress_ptr cinfo,
55 cjpeg_source_ptr sinfo));
60 JDIMENSION buffer_height;
65 * Object interface for djpeg's output file encoding modules
68 typedef struct djpeg_dest_struct * djpeg_dest_ptr;
70 struct djpeg_dest_struct {
71 /* start_output is called after jpeg_start_decompress finishes.
72 * The color map will be ready at this time, if one is needed.
74 JMETHOD(void, start_output, (j_decompress_ptr cinfo,
75 djpeg_dest_ptr dinfo));
76 /* Emit the specified number of pixel rows from the buffer. */
77 JMETHOD(void, put_pixel_rows, (j_decompress_ptr cinfo,
79 JDIMENSION rows_supplied));
80 /* Finish up at the end of the image. */
81 JMETHOD(void, finish_output, (j_decompress_ptr cinfo,
82 djpeg_dest_ptr dinfo));
84 /* Target file spec; filled in by djpeg.c after object is created. */
87 /* Output pixel-row buffer. Created by module init or start_output.
88 * Width is cinfo->output_width * cinfo->output_components;
89 * height is buffer_height.
92 JDIMENSION buffer_height;
97 * cjpeg/djpeg may need to perform extra passes to convert to or from
98 * the source/destination file format. The JPEG library does not know
99 * about these passes, but we'd like them to be counted by the progress
100 * monitor. We use an expanded progress monitor object to hold the
101 * additional pass count.
104 struct cdjpeg_progress_mgr {
105 struct jpeg_progress_mgr pub; /* fields known to JPEG library */
106 int completed_extra_passes; /* extra passes completed */
107 int total_extra_passes; /* total extra */
108 /* last printed percentage stored here to avoid multiple printouts */
112 typedef struct cdjpeg_progress_mgr * cd_progress_ptr;
115 /* Short forms of external names for systems with brain-damaged linkers. */
117 #ifdef NEED_SHORT_EXTERNAL_NAMES
118 #define jinit_read_bmp jIRdBMP
119 #define jinit_write_bmp jIWrBMP
120 #define jinit_read_gif jIRdGIF
121 #define jinit_write_gif jIWrGIF
122 #define jinit_read_ppm jIRdPPM
123 #define jinit_write_ppm jIWrPPM
124 #define jinit_read_rle jIRdRLE
125 #define jinit_write_rle jIWrRLE
126 #define jinit_read_targa jIRdTarga
127 #define jinit_write_targa jIWrTarga
128 #define read_quant_tables RdQTables
129 #define read_scan_script RdScnScript
130 #define set_quant_slots SetQSlots
131 #define set_sample_factors SetSFacts
132 #define read_color_map RdCMap
133 #define enable_signal_catcher EnSigCatcher
134 #define start_progress_monitor StProgMon
135 #define end_progress_monitor EnProgMon
136 #define read_stdin RdStdin
137 #define write_stdout WrStdout
138 #endif /* NEED_SHORT_EXTERNAL_NAMES */
140 /* Module selection routines for I/O modules. */
142 EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo));
143 EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo,
145 EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo));
146 EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo));
147 EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo));
148 EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo));
149 EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo));
150 EXTERN(djpeg_dest_ptr) jinit_write_rle JPP((j_decompress_ptr cinfo));
151 EXTERN(cjpeg_source_ptr) jinit_read_targa JPP((j_compress_ptr cinfo));
152 EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo));
154 /* cjpeg support routines (in rdswitch.c) */
156 EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename,
157 int scale_factor, boolean force_baseline));
158 EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename));
159 EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg));
160 EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg));
162 /* djpeg support routines (in rdcolmap.c) */
164 EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE * infile));
166 /* common support routines (in cdjpeg.c) */
168 EXTERN(void) enable_signal_catcher JPP((j_common_ptr cinfo));
169 EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo,
170 cd_progress_ptr progress));
171 EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo));
172 EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars));
173 EXTERN(FILE *) read_stdin JPP((void));
174 EXTERN(FILE *) write_stdout JPP((void));
176 /* miscellaneous useful macros */
178 #ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */
179 #define READ_BINARY "r"
180 #define WRITE_BINARY "w"
182 #define READ_BINARY "rb"
183 #define WRITE_BINARY "wb"
186 #ifndef EXIT_FAILURE /* define exit() codes if not provided */
187 #define EXIT_FAILURE 1
191 #define EXIT_SUCCESS 1 /* VMS is very nonstandard */
193 #define EXIT_SUCCESS 0
198 #define EXIT_WARNING 1 /* VMS is very nonstandard */
200 #define EXIT_WARNING 2