41#ifdef HAVE_UNSIGNED_CHAR
42typedef unsigned char U_CHAR;
43#define UCH(x) ((int) (x))
46#ifdef CHAR_IS_UNSIGNED
47#define UCH(x) ((int) (x))
49#define UCH(x) ((int) (x) & 0xFF)
54#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len)))
80typedef ppm_source_struct * ppm_source_ptr;
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);
121 while ((ch = pbm_getc(
infile)) >=
'0' && ch <=
'9') {
148 unsigned int maxval =
source->maxval;
153 register unsigned int temp;
156 ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
171 unsigned int maxval =
source->maxval;
176 register unsigned int temp;
179 ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
183 ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
187 ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
200 register U_CHAR * bufferptr;
202 unsigned int maxval =
source->maxval;
206 ERREXIT(cinfo, JERR_INPUT_EOF);
208 bufferptr =
source->iobuffer;
210 register unsigned int temp;
211 temp = (
unsigned int) UCH(*bufferptr++);
213 ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
226 register U_CHAR * bufferptr;
228 unsigned int maxval =
source->maxval;
232 ERREXIT(cinfo, JERR_INPUT_EOF);
234 bufferptr =
source->iobuffer;
236 register unsigned int temp;
237 temp = (
unsigned int) UCH(*bufferptr++);
239 ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
241 temp = (
unsigned int) UCH(*bufferptr++);
243 ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
245 temp = (
unsigned int) UCH(*bufferptr++);
247 ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
264 ERREXIT(cinfo, JERR_INPUT_EOF);
275 register U_CHAR * bufferptr;
277 unsigned int maxval =
source->maxval;
281 ERREXIT(cinfo, JERR_INPUT_EOF);
283 bufferptr =
source->iobuffer;
285 register unsigned int temp;
286 temp = ((
unsigned int) UCH(*bufferptr++)) << 8;
287 temp |= (
unsigned int) UCH(*bufferptr++);
289 ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
302 register U_CHAR * bufferptr;
304 unsigned int maxval =
source->maxval;
308 ERREXIT(cinfo, JERR_INPUT_EOF);
310 bufferptr =
source->iobuffer;
312 register unsigned int temp;
313 temp = ((
unsigned int) UCH(*bufferptr++)) << 8;
314 temp |= (
unsigned int) UCH(*bufferptr++);
316 ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
318 temp = ((
unsigned int) UCH(*bufferptr++)) << 8;
319 temp |= (
unsigned int) UCH(*bufferptr++);
321 ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
323 temp = ((
unsigned int) UCH(*bufferptr++)) << 8;
324 temp |= (
unsigned int) UCH(*bufferptr++);
326 ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
342 unsigned int w,
h, maxval;
343 boolean need_iobuffer, use_raw_buffer, need_rescale;
362 w = read_pbm_integer(cinfo,
source->pub.input_file);
363 h = read_pbm_integer(cinfo,
source->pub.input_file);
364 maxval = read_pbm_integer(cinfo,
source->pub.input_file);
366 if (
w <= 0 ||
h <= 0 || maxval <= 0)
369 if (((
long)
w >> 24) ||
370 ((
long) maxval >> 16))
371 ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
379 need_iobuffer =
TRUE;
380 use_raw_buffer =
FALSE;
388 source->pub.get_pixel_rows = get_text_gray_row;
389 need_iobuffer =
FALSE;
396 source->pub.get_pixel_rows = get_text_rgb_row;
397 need_iobuffer =
FALSE;
405 source->pub.get_pixel_rows = get_word_gray_row;
407 source->pub.get_pixel_rows = get_raw_row;
408 use_raw_buffer =
TRUE;
409 need_rescale =
FALSE;
411 source->pub.get_pixel_rows = get_scaled_gray_row;
420 source->pub.get_pixel_rows = get_word_rgb_row;
422 source->pub.get_pixel_rows = get_raw_row;
423 use_raw_buffer =
TRUE;
424 need_rescale =
FALSE;
426 source->pub.get_pixel_rows = get_scaled_rgb_row;
434 ((maxval <= 255) ?
SIZEOF(U_CHAR) : (2 *
SIZEOF(U_CHAR)));
435 source->iobuffer = (U_CHAR *) (*cinfo->mem->alloc_small)
440 if (use_raw_buffer) {
446 source->pub.buffer_height = 1;
451 source->pub.buffer_height = 1;
461 half_maxval = maxval / 2;
491 source = (ppm_source_ptr) (*cinfo->mem->alloc_small)
494 source->pub.start_input = start_input_ppm;
495 source->pub.finish_input = finish_input_ppm;
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLubyte GLubyte GLubyte GLubyte w
GLfloat GLfloat GLfloat GLfloat h
_Check_return_ _CRTIMP int __cdecl getc(_Inout_ FILE *_File)
#define TRACEMS2(cinfo, lvl, code, p1, p2)
struct jpeg_common_struct * j_common_ptr
J_COLOR_SPACE in_color_space
#define ReadOK(tif, buf, size)