41 #ifdef HAVE_UNSIGNED_CHAR 43 #define UCH(x) ((int) (x)) 45 #ifdef CHAR_IS_UNSIGNED 47 #define UCH(x) ((int) (x)) 50 #define UCH(x) ((int) (x) & 0xFF) 55 #define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) 94 }
while (ch !=
'\n' && ch !=
EOF);
108 register unsigned int val;
114 ERREXIT(cinfo, JERR_INPUT_EOF);
115 }
while (ch ==
' ' || ch ==
'\t' || ch ==
'\n' || ch ==
'\r');
117 if (ch < '0' || ch >
'9')
118 ERREXIT(cinfo, JERR_PPM_NONNUMERIC);
151 for (col = cinfo->image_width; col > 0; col--) {
169 for (col = cinfo->image_width; col > 0; col--) {
184 register U_CHAR * bufferptr;
189 ERREXIT(cinfo, JERR_INPUT_EOF);
191 bufferptr =
source->iobuffer;
192 for (col = cinfo->image_width; col > 0; col--) {
193 *
ptr++ = rescale[
UCH(*bufferptr++)];
205 register U_CHAR * bufferptr;
210 ERREXIT(cinfo, JERR_INPUT_EOF);
212 bufferptr =
source->iobuffer;
213 for (col = cinfo->image_width; col > 0; col--) {
214 *
ptr++ = rescale[
UCH(*bufferptr++)];
215 *
ptr++ = rescale[
UCH(*bufferptr++)];
216 *
ptr++ = rescale[
UCH(*bufferptr++)];
232 ERREXIT(cinfo, JERR_INPUT_EOF);
243 register U_CHAR * bufferptr;
248 ERREXIT(cinfo, JERR_INPUT_EOF);
250 bufferptr =
source->iobuffer;
251 for (col = cinfo->image_width; col > 0; col--) {
253 temp =
UCH(*bufferptr++);
254 temp |=
UCH(*bufferptr++) << 8;
255 *
ptr++ = rescale[temp];
267 register U_CHAR * bufferptr;
272 ERREXIT(cinfo, JERR_INPUT_EOF);
274 bufferptr =
source->iobuffer;
275 for (col = cinfo->image_width; col > 0; col--) {
277 temp =
UCH(*bufferptr++);
278 temp |=
UCH(*bufferptr++) << 8;
279 *
ptr++ = rescale[temp];
280 temp =
UCH(*bufferptr++);
281 temp |=
UCH(*bufferptr++) << 8;
282 *
ptr++ = rescale[temp];
283 temp =
UCH(*bufferptr++);
284 temp |=
UCH(*bufferptr++) << 8;
285 *
ptr++ = rescale[temp];
300 unsigned int w,
h, maxval;
301 boolean need_iobuffer, use_raw_buffer, need_rescale;
303 if (getc(
source->pub.input_file) !=
'P')
306 c = getc(
source->pub.input_file);
325 if (
w <= 0 ||
h <= 0 || maxval <= 0)
333 need_iobuffer =
TRUE;
334 use_raw_buffer =
FALSE;
339 cinfo->input_components = 1;
343 need_iobuffer =
FALSE;
347 cinfo->input_components = 3;
348 cinfo->in_color_space =
JCS_RGB;
351 need_iobuffer =
FALSE;
355 cinfo->input_components = 1;
362 use_raw_buffer =
TRUE;
363 need_rescale =
FALSE;
370 cinfo->input_components = 3;
371 cinfo->in_color_space =
JCS_RGB;
377 use_raw_buffer =
TRUE;
378 need_rescale =
FALSE;
387 source->buffer_width = (size_t)
w * cinfo->input_components *
395 if (use_raw_buffer) {
401 source->pub.buffer_height = 1;
404 source->pub.buffer = (*cinfo->mem->alloc_sarray)
407 source->pub.buffer_height = 1;
418 half_maxval = maxval / 2;
419 for (val = 0; val <= (
INT32) maxval; val++) {
450 SIZEOF(ppm_source_struct));
start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
get_word_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
#define ReadOK(file, buffer, len)
struct jpeg_common_struct * j_common_ptr
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLsizei GLchar * source
#define ERREXIT(cinfo, code)
#define TRACEMS2(cinfo, lvl, code, p1, p2)
get_scaled_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
get_raw_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
read_pbm_integer(j_compress_ptr cinfo, FILE *infile)
get_text_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
typedef long(ZCALLBACK *tell_file_func) OF((voidpf opaque
ppm_source_struct * ppm_source_ptr
get_scaled_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
get_word_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
GLubyte GLubyte GLubyte GLubyte w
jinit_read_ppm(j_compress_ptr cinfo)
get_text_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
finish_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)