22 #ifdef TARGA_SUPPORTED
27 #ifdef HAVE_UNSIGNED_CHAR
29 #define UCH(x) ((int) (x))
31 #ifdef CHAR_IS_UNSIGNED
33 #define UCH(x) ((int) (x))
36 #define UCH(x) ((int) (x) & 0xFF)
41 #define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len)))
79 0, 8, 16, 25, 33, 41, 49, 58,
80 66, 74, 82, 90, 99, 107, 115, 123,
81 132, 140, 148, 156, 165, 173, 181, 189,
82 197, 206, 214, 222, 230, 239, 247, 255
91 register FILE *
infile = sinfo->pub.input_file;
95 ERREXIT(sinfo->cinfo, JERR_INPUT_EOF);
107 if (mapentrysize != 24)
108 ERREXIT(sinfo->cinfo, JERR_TGA_BADCMAP);
110 for (
i = 0;
i < cmaplen;
i++) {
126 register FILE *
infile = sinfo->pub.input_file;
129 for (
i = 0;
i < sinfo->pixel_size;
i++) {
139 register FILE *
infile = sinfo->pub.input_file;
143 if (sinfo->dup_pixel_count > 0) {
144 sinfo->dup_pixel_count--;
149 if (--sinfo->block_count < 0) {
152 sinfo->dup_pixel_count =
i & 0x7F;
153 sinfo->block_count = 0;
155 sinfo->block_count =
i & 0x7F;
160 for (
i = 0;
i < sinfo->pixel_size;
i++) {
182 for (col = cinfo->image_width; col > 0; col--) {
183 (*source->read_pixel) (source);
200 for (col = cinfo->image_width; col > 0; col--) {
201 (*source->read_pixel) (source);
203 *
ptr++ = colormap[0][t];
204 *
ptr++ = colormap[1][t];
205 *
ptr++ = colormap[2][t];
220 for (col = cinfo->image_width; col > 0; col--) {
221 (*source->read_pixel) (source);
247 for (col = cinfo->image_width; col > 0; col--) {
248 (*source->read_pixel) (source);
263 #define get_32bit_row get_24bit_row
284 source->
pub.
buffer = (*cinfo->mem->access_virt_sarray)
313 source->
pub.
buffer = (*cinfo->mem->access_virt_sarray)
315 (*source->get_pixel_rows) (cinfo, sinfo);
337 int idlen, cmaptype, subtype,
flags, interlace_type, components;
339 boolean is_bottom_up;
341 #define GET_2B(offset) ((unsigned int) UCH(targaheader[offset]) + \
342 (((unsigned int) UCH(targaheader[offset+1])) << 8))
345 ERREXIT(cinfo, JERR_INPUT_EOF);
348 if (targaheader[16] == 15)
349 targaheader[16] = 16;
351 idlen =
UCH(targaheader[0]);
352 cmaptype =
UCH(targaheader[1]);
353 subtype =
UCH(targaheader[2]);
360 is_bottom_up = ((
flags & 0x20) == 0);
361 interlace_type =
flags >> 6;
365 (
UCH(targaheader[16]) & 7) != 0 ||
367 ERREXIT(cinfo, JERR_TGA_BADPARMS);
381 cinfo->in_color_space =
JCS_RGB;
388 ERREXIT(cinfo, JERR_TGA_BADPARMS);
403 ERREXIT(cinfo, JERR_TGA_BADPARMS);
414 ERREXIT(cinfo, JERR_TGA_BADPARMS);
418 ERREXIT(cinfo, JERR_TGA_BADPARMS);
424 source->
whole_image = (*cinfo->mem->request_virt_sarray)
427 if (cinfo->progress != NULL) {
437 source->
pub.
buffer = (*cinfo->mem->alloc_sarray)
441 source->
pub.get_pixel_rows = source->get_pixel_rows;
448 if (maplen > 256 ||
GET_2B(3) != 0)
449 ERREXIT(cinfo, JERR_TGA_BADCMAP);
451 source->
colormap = (*cinfo->mem->alloc_sarray)
457 ERREXIT(cinfo, JERR_TGA_BADPARMS);
461 cinfo->input_components = components;
462 cinfo->data_precision = 8;
463 cinfo->image_width =
width;
464 cinfo->image_height =
height;
492 source->
cinfo = cinfo;