18 #undef LOCAL // fix from a jpeg header, pstypes.h will define it again
33 struct jpeg_source_mgr pub;
44 #define INPUT_BUF_SIZE 4096 // choose an efficiently read'able size
46 static int jpeg_error_code;
49 #define Jpeg_Set_Error(x) { jpeg_error_code = x; }
59 (*cinfo->err->output_message) (cinfo);
76 char buffer[JMSG_LENGTH_MAX];
79 (*cinfo->err->format_message) (cinfo, buffer);
101 CFILE *jpeg_file = NULL;
104 if (img_cfp == NULL) {
105 strcpy_s( filename, real_filename );
107 char *
p = strchr( filename,
'.' );
114 jpeg_file =
cfopen( filename ,
"rb" );
123 Assert( jpeg_file != NULL );
125 if (jpeg_file == NULL)
146 if (bpp) *bpp = (
jpeg_info.num_components * 8);
151 if (img_cfp == NULL) {
156 return jpeg_error_code;
170 CFILE *img_cfp = NULL;
173 strcpy_s( filename, real_filename );
174 char *
p = strchr( filename,
'.' );
212 jpeg_info.out_color_components = dest_size;
224 jpeg_read_scanlines(&
jpeg_info, buffer, 1);
232 for (
int k = 2; k <
size; k += 3) {
233 tmp = buffer[0][k - 2];
234 buffer[0][k - 2] = buffer[0][k];
238 memcpy(image_data, *buffer, size);
252 return jpeg_error_code;
285 src->
buffer[0] = (JOCTET) 0xFF;
286 src->
buffer[1] = (JOCTET) JPEG_EOI;
293 src->
pub.bytes_in_buffer = nbytes;
304 while (num_bytes > (
long) src->
pub.bytes_in_buffer) {
305 num_bytes -= (long) src->
pub.bytes_in_buffer;
311 src->
pub.next_input_byte += (size_t) num_bytes;
312 src->
pub.bytes_in_buffer -= (size_t) num_bytes;
325 if (cinfo->src == NULL) {
326 cinfo->src = (
struct jpeg_source_mgr *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
sizeof(
cfile_source_mgr));
328 src->
buffer = (JOCTET *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
INPUT_BUF_SIZE *
sizeof(JOCTET));
335 src->
pub.resync_to_restart = jpeg_resync_to_restart;
338 src->
pub.bytes_in_buffer = 0;
339 src->
pub.next_input_byte = NULL;
GLfloat GLfloat GLfloat GLfloat h
#define Jpeg_Set_Error(x)
struct jpeg_error_mgr jpeg_err
void jpg_error_exit(j_common_ptr cinfo)
int cfread(void *buf, int elsize, int nelem, CFILE *fp)
void _cdecl void void _cdecl void _cdecl Warning(char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
struct jpeg_decompress_struct jpeg_info
struct jpeg_source_mgr pub
void jpeg_cfile_src(j_decompress_ptr cinfo, CFILE *cfp)
int jpeg_read_bitmap(const char *real_filename, ubyte *image_data, ubyte *palette, int dest_size, int cf_type)
void jpeg_cf_init_source(j_decompress_ptr cinfo)
void jpeg_cf_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
boolean jpeg_cf_fill_input_buffer(j_decompress_ptr cinfo)
void jpg_output_message(j_common_ptr cinfo)
GLubyte GLubyte GLubyte GLubyte w
cfile_source_mgr * cfile_src_ptr
#define JPEG_ERROR_READING
void jpeg_cf_term_source(j_decompress_ptr cinfo)
int cfclose(CFILE *cfile)
int jpeg_read_header(const char *real_filename, CFILE *img_cfp, int *w, int *h, int *bpp, ubyte *palette)