32#ifdef HAVE_UNSIGNED_CHAR
33typedef unsigned char U_CHAR;
34#define UCH(x) ((int) (x))
37#ifdef CHAR_IS_UNSIGNED
38#define UCH(x) ((int) (x))
40#define UCH(x) ((int) (x) & 0xFF)
45#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len)))
50typedef struct _bmp_source_struct * bmp_source_ptr;
52typedef struct _bmp_source_struct {
82read_colormap (bmp_source_ptr
sinfo,
int cmaplen,
int mapentrysize)
87 switch (mapentrysize) {
90 for (
i = 0;
i < cmaplen;
i++) {
98 for (
i = 0;
i < cmaplen;
i++) {
131 inptr = * (*cinfo->mem->access_virt_sarray) ((
j_common_ptr) cinfo,
135 outptr =
source->pub.buffer[0];
136 colormap =
source->colormap;
137 cmaplen =
source->cmap_length;
141 ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
142 *outptr++ = colormap[0][
t];
143 *outptr++ = colormap[1][
t];
144 *outptr++ = colormap[2][
t];
160 inptr = * (*cinfo->mem->access_virt_sarray) ((
j_common_ptr) cinfo,
166 outptr =
source->pub.buffer[0];
168 outptr[2] = *inptr++;
169 outptr[1] = *inptr++;
170 outptr[0] = *inptr++;
187 inptr = * (*cinfo->mem->access_virt_sarray) ((
j_common_ptr) cinfo,
193 outptr =
source->pub.buffer[0];
195 outptr[2] = *inptr++;
196 outptr[1] = *inptr++;
197 outptr[0] = *inptr++;
229 out_ptr = * (*cinfo->mem->access_virt_sarray) ((
j_common_ptr) cinfo,
231 for (col =
source->row_width; col > 0; col--) {
234 ERREXIT(cinfo, JERR_INPUT_EOF);
242 switch (
source->bits_per_pixel) {
244 source->pub.get_pixel_rows = get_8bit_row;
247 source->pub.get_pixel_rows = get_24bit_row;
250 source->pub.get_pixel_rows = get_32bit_row;
253 ERREXIT(cinfo, JERR_BMP_BADDEPTH);
258 return (*
source->pub.get_pixel_rows) (cinfo,
sinfo);
270 U_CHAR bmpfileheader[14];
271 U_CHAR bmpinfoheader[64];
272#define GET_2B(array, offset) ((unsigned int) UCH(array[offset]) + \
273 (((unsigned int) UCH(array[offset+1])) << 8))
274#define GET_4B(array, offset) ((INT32) UCH(array[offset]) + \
275 (((INT32) UCH(array[offset+1])) << 8) + \
276 (((INT32) UCH(array[offset+2])) << 16) + \
277 (((INT32) UCH(array[offset+3])) << 24))
282 unsigned int biPlanes;
284 INT32 biXPelsPerMeter,biYPelsPerMeter;
286 int mapentrysize = 0;
291 if (!
ReadOK(
source->pub.input_file, bmpfileheader, 14))
292 ERREXIT(cinfo, JERR_INPUT_EOF);
293 if (GET_2B(bmpfileheader, 0) != 0x4D42)
295 bfOffBits = GET_4B(bmpfileheader, 10);
302 ERREXIT(cinfo, JERR_INPUT_EOF);
303 headerSize = GET_4B(bmpinfoheader, 0);
304 if (headerSize < 12 || headerSize > 64)
305 ERREXIT(cinfo, JERR_BMP_BADHEADER);
306 if (!
ReadOK(
source->pub.input_file, bmpinfoheader + 4, headerSize - 4))
307 ERREXIT(cinfo, JERR_INPUT_EOF);
309 switch ((
int) headerSize) {
312 biWidth = (
INT32) GET_2B(bmpinfoheader, 4);
313 biHeight = (
INT32) GET_2B(bmpinfoheader, 6);
314 biPlanes = GET_2B(bmpinfoheader, 8);
315 source->bits_per_pixel = (
int) GET_2B(bmpinfoheader, 10);
317 switch (
source->bits_per_pixel) {
320 TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, (
int) biWidth, (
int) biHeight);
324 TRACEMS3(cinfo, 1, JTRC_BMP_OS2, (
int) biWidth, (
int) biHeight,
328 ERREXIT(cinfo, JERR_BMP_BADDEPTH);
335 biWidth = GET_4B(bmpinfoheader, 4);
336 biHeight = GET_4B(bmpinfoheader, 8);
337 biPlanes = GET_2B(bmpinfoheader, 12);
338 source->bits_per_pixel = (
int) GET_2B(bmpinfoheader, 14);
339 biCompression = GET_4B(bmpinfoheader, 16);
340 biXPelsPerMeter = GET_4B(bmpinfoheader, 24);
341 biYPelsPerMeter = GET_4B(bmpinfoheader, 28);
342 biClrUsed = GET_4B(bmpinfoheader, 32);
345 switch (
source->bits_per_pixel) {
348 TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, (
int) biWidth, (
int) biHeight);
352 TRACEMS3(cinfo, 1, JTRC_BMP, (
int) biWidth, (
int) biHeight,
356 ERREXIT(cinfo, JERR_BMP_BADDEPTH);
358 if (biCompression != 0)
359 ERREXIT(cinfo, JERR_BMP_COMPRESSED);
361 if (biXPelsPerMeter > 0 && biYPelsPerMeter > 0) {
369 ERREXIT(cinfo, JERR_BMP_BADHEADER);
374 ERREXIT(cinfo, JERR_BMP_BADPLANES);
376 if (biWidth <= 0 || biHeight <= 0 || (biWidth >> 24) || (biHeight >> 24))
377 ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
380 bPad = bfOffBits - (headerSize + 14);
383 if (mapentrysize > 0) {
386 else if (biClrUsed > 256)
387 ERREXIT(cinfo, JERR_BMP_BADCMAP);
393 read_colormap(
source, (
int) biClrUsed, mapentrysize);
395 bPad -= biClrUsed * mapentrysize;
400 ERREXIT(cinfo, JERR_BMP_BADHEADER);
401 while (--bPad >= 0) {
406 if (
source->bits_per_pixel == 24)
408 else if (
source->bits_per_pixel == 32)
412 while ((row_width & 3) != 0) row_width++;
413 source->row_width = row_width;
416 source->whole_image = (*cinfo->mem->request_virt_sarray)
419 source->pub.get_pixel_rows = preload_image;
420 if (cinfo->progress !=
NULL) {
428 source->pub.buffer_height = 1;
459 source = (bmp_source_ptr) (*cinfo->mem->alloc_small)
463 source->pub.start_input = start_input_bmp;
464 source->pub.finish_input = finish_input_bmp;
struct cdjpeg_progress_mgr * cd_progress_ptr
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_Check_return_ _CRTIMP int __cdecl getc(_Inout_ FILE *_File)
#define TRACEMS2(cinfo, lvl, code, p1, p2)
#define TRACEMS3(cinfo, lvl, code, p1, p2, p3)
#define GETJSAMPLE(value)
struct jpeg_common_struct * j_common_ptr
struct jpeg_progress_mgr pub
int completed_extra_passes
J_COLOR_SPACE in_color_space
#define ReadOK(tif, buf, size)