X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fjpeg.c;h=1c5e91c9da15fe671e74e9cbc020199b0c3b5d8f;hp=f9cdf414a16be5a67d23c7e1e0045a846f6e3561;hb=a4be97bc967c8aceac1c893cbbe307b23b603683;hpb=90aec6a9d4522c29c75bc85d5b4fd58e544fc3a3 diff --git a/lib/jpeg.c b/lib/jpeg.c index f9cdf41..1c5e91c 100644 --- a/lib/jpeg.c +++ b/lib/jpeg.c @@ -405,6 +405,29 @@ int jpeg_load(const char*filename, unsigned char**dest, int*_width, int*_height) return 1; } +void jpeg_get_size(const char *filename, int *width, int *height) +{ + struct jpeg_decompress_struct cinfo; + struct jpeg_error_mgr jerr; + FILE *fi; + *width = 0; + *height = 0; + cinfo.err = jpeg_std_error(&jerr); + cinfo.image_width = 0; + cinfo.image_height = 0; + jpeg_create_decompress(&cinfo); + if ((fi = fopen(filename, "rb")) == NULL) { + fprintf(stderr, "couldn't open %s\n", filename); + return; + } + jpeg_stdio_src(&cinfo, fi); + jpeg_read_header(&cinfo, TRUE); + *width = cinfo.image_width; + *height = cinfo.image_height; + jpeg_destroy_decompress(&cinfo); + fclose(fi); +} + #else int jpeg_save(unsigned char*data, int width, int height, int quality, const char*filename) @@ -432,5 +455,11 @@ int jpeg_load(const char*filename, unsigned char**dest, int*_width, int*_height) fprintf(stderr, "jpeg_load: No JPEG support compiled in\n"); return 0; } +void jpeg_get_size(const char *fname, int *width, int *height) +{ + *width = 0; + *height = 0; + fprintf(stderr, "jpeg_get_size: No JPEG support compiled in\n"); +} #endif