X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fjpeg.c;h=21cc0f7cc897ecd80c4482a77bc64782dc0a570e;hp=1c5e91c9da15fe671e74e9cbc020199b0c3b5d8f;hb=9b328ffcb7522c4c0d021a1a8c68e95390e1b2a7;hpb=9e1987ca321def20b6f756bb5955d41c78c45c05 diff --git a/lib/jpeg.c b/lib/jpeg.c index 1c5e91c..21cc0f7 100644 --- a/lib/jpeg.c +++ b/lib/jpeg.c @@ -288,12 +288,11 @@ void mem_term_source (j_decompress_ptr cinfo) //printf("term %d\n", size - mgr->bytes_in_buffer); } -int jpeg_load_from_mem(unsigned char*_data, int _size, unsigned char*dest, int width, int height) +int jpeg_load_from_mem(unsigned char*_data, int _size, unsigned char**dest, int*width, int*height) { struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; struct jpeg_source_mgr mgr; - int y,x; data = _data; size = _size; @@ -312,12 +311,27 @@ int jpeg_load_from_mem(unsigned char*_data, int _size, unsigned char*dest, int w cinfo.src = &mgr; jpeg_read_header(&cinfo, TRUE); + cinfo.out_color_space == JCS_RGB; jpeg_start_decompress(&cinfo); + + *width = cinfo.output_width; + *height = cinfo.output_height; + *dest = malloc(cinfo.output_width * cinfo.output_height * 4); - for(y=0;y