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))) 48 typedef struct _tga_source_struct {
78 static const UINT8 c5to8bits[32] = {
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--) {
200 for (col = cinfo->image_width; col > 0; col--) {
203 *
ptr++ = colormap[0][
t];
204 *
ptr++ = colormap[1][
t];
205 *
ptr++ = colormap[2][
t];
220 for (col = cinfo->image_width; col > 0; col--) {
247 for (col = cinfo->image_width; col > 0; col--) {
263 #define get_32bit_row get_24bit_row 281 source_row = cinfo->image_height - source->current_row - 1;
284 source->pub.buffer = (*cinfo->mem->access_virt_sarray)
288 source->current_row++;
308 if (progress !=
NULL) {
313 source->pub.buffer = (*cinfo->mem->access_virt_sarray)
315 (*
source->get_pixel_rows) (cinfo, sinfo);
317 if (progress !=
NULL)
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]);
357 source->pixel_size =
UCH(targaheader[16]) >> 3;
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;
385 if (
source->pixel_size == 1 && cmaptype == 1)
388 ERREXIT(cinfo, JERR_TGA_BADPARMS);
392 switch (
source->pixel_size) {
403 ERREXIT(cinfo, JERR_TGA_BADPARMS);
411 if (
source->pixel_size == 1)
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) {
432 source->pub.buffer_height = 1;
437 source->pub.buffer = (*cinfo->mem->alloc_sarray)
440 source->pub.buffer_height = 1;
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);
462 cinfo->data_precision = 8;
463 cinfo->image_width =
width;
464 cinfo->image_height =
height;
GLint GLint GLsizei GLsizei height
struct _tga_source_struct tga_source_struct
for(n=1;n< outline->n_points;n++)
struct jpeg_common_struct * j_common_ptr
GLsizei GLsizei GLchar * source
GLenum GLenum GLuint components
GLint GLint GLsizei width
#define ERREXIT(cinfo, code)
#define TRACEMS2(cinfo, lvl, code, p1, p2)
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
GLenum GLenum GLvoid * row
struct _tga_source_struct * tga_source_ptr
jinit_read_targa(j_compress_ptr cinfo)
get_8bit_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
get_16bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
get_memory_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
get_24bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
#define JMETHOD(type, methodname, arglist)
typedef long(ZCALLBACK *tell_file_func) OF((voidpf opaque
preload_image(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
get_8bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
struct jpeg_progress_mgr pub
read_colormap(tga_source_ptr sinfo, int cmaplen, int mapentrysize)
read_non_rle_pixel(tga_source_ptr sinfo)
int completed_extra_passes
struct cdjpeg_progress_mgr * cd_progress_ptr
read_byte(tga_source_ptr sinfo)
start_input_tga(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
finish_input_tga(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
read_rle_pixel(tga_source_ptr sinfo)
struct jvirt_sarray_control * jvirt_sarray_ptr
#define ReadOK(file, buffer, len)