X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fjpeg.c;h=71483f6405fdb51a0c16a4dcb9a7797cb463afe7;hp=d58215c27b0c49e6ef8f3e3a7ced0b2126aa895a;hb=2391d7ae5d8a145a250a8b80ab8c93ba74eba030;hpb=6aed88dfdec745e702a15f44ea058a21342729a0 diff --git a/lib/jpeg.c b/lib/jpeg.c index d58215c..71483f6 100644 --- a/lib/jpeg.c +++ b/lib/jpeg.c @@ -227,7 +227,7 @@ boolean mem_fill_input_buffer (j_decompress_ptr cinfo) void mem_skip_input_data (j_decompress_ptr cinfo, long num_bytes) { struct jpeg_source_mgr* mgr = cinfo->src; - printf("skip %d +%d\n", size - mgr->bytes_in_buffer, num_bytes); + printf("skip %d +%ld\n", size - mgr->bytes_in_buffer, num_bytes); if(num_bytes<=0) return; mgr->next_input_byte += num_bytes; @@ -298,12 +298,10 @@ int jpeg_load(const char*filename, unsigned char**dest, int*_width, int*_height) struct jpeg_source_mgr mgr; FILE*fi = fopen(filename, "rb"); - if(!fi) + if(!fi) { + fprintf(stderr, "Couldn't open file %s\n", filename); return 0; - fseek(fi, SEEK_END, 0); - long filesize = ftell(fi); - fseek(fi, SEEK_SET, 0); - fclose(fi); + } cinfo.err = jpeg_std_error(&jerr); jpeg_create_decompress(&cinfo); @@ -315,13 +313,13 @@ int jpeg_load(const char*filename, unsigned char**dest, int*_width, int*_height) int width = *_width = cinfo.output_width; int height = *_height = cinfo.output_height; - *dest = malloc(width*height*4); + *dest = (unsigned char*)malloc(width*height*4); int y; for (y=0;y