* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2017, D. R. Commander.
+ * Copyright (C) 2017, 2019, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
char targaheader[18];
/* Set unused fields of header to 0 */
- MEMZERO(targaheader, sizeof(targaheader));
+ memset(targaheader, 0, sizeof(targaheader));
if (num_colors > 0) {
targaheader[1] = 1; /* color map type 1 */
}
}
- if (JFWRITE(dinfo->output_file, targaheader, 18) != (size_t)18)
+ if (fwrite(targaheader, 1, 18, dinfo->output_file) != (size_t)18)
ERREXIT(cinfo, JERR_FILE_WRITE);
}
inptr = dest->pub.buffer[0];
outptr = dest->iobuffer;
for (col = cinfo->output_width; col > 0; col--) {
- outptr[0] = (char)GETJSAMPLE(inptr[2]); /* RGB to BGR order */
- outptr[1] = (char)GETJSAMPLE(inptr[1]);
- outptr[2] = (char)GETJSAMPLE(inptr[0]);
+ outptr[0] = inptr[2]; /* RGB to BGR order */
+ outptr[1] = inptr[1];
+ outptr[2] = inptr[0];
inptr += 3, outptr += 3;
}
- (void)JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
+ fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
}
METHODDEF(void)
tga_dest_ptr dest = (tga_dest_ptr)dinfo;
register JSAMPROW inptr;
register char *outptr;
- register JDIMENSION col;
inptr = dest->pub.buffer[0];
outptr = dest->iobuffer;
- for (col = cinfo->output_width; col > 0; col--) {
- *outptr++ = (char)GETJSAMPLE(*inptr++);
- }
- (void)JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
+ memcpy(outptr, inptr, cinfo->output_width);
+ fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
}
inptr = dest->pub.buffer[0];
outptr = dest->iobuffer;
for (col = cinfo->output_width; col > 0; col--) {
- *outptr++ = (char)GETJSAMPLE(color_map0[GETJSAMPLE(*inptr++)]);
+ *outptr++ = color_map0[*inptr++];
}
- (void)JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
+ fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
}
/* Write the colormap. Note Targa uses BGR byte order */
outfile = dest->pub.output_file;
for (i = 0; i < num_colors; i++) {
- putc(GETJSAMPLE(cinfo->colormap[2][i]), outfile);
- putc(GETJSAMPLE(cinfo->colormap[1][i]), outfile);
- putc(GETJSAMPLE(cinfo->colormap[0][i]), outfile);
+ putc(cinfo->colormap[2][i], outfile);
+ putc(cinfo->colormap[1][i], outfile);
+ putc(cinfo->colormap[0][i], outfile);
}
dest->pub.put_pixel_rows = put_gray_rows;
} else {
{
tga_dest_ptr dest;
+ if (cinfo->data_precision != 8)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
/* Create module interface object, fill in method pointers */
dest = (tga_dest_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,