- for(y=0;y<height;y++) {
- unsigned char*j = &dest[width*y*3];
- jpeg_read_scanlines(&cinfo,&j,1);
+ unsigned char*scanline = malloc(cinfo.output_width * 4);
+ int y;
+ for(y=0;y<cinfo.output_height;y++) {
+ unsigned char*to = &(*dest)[cinfo.output_width*y*4];
+ jpeg_read_scanlines(&cinfo,&scanline,1);
+ int x;
+ for(x=0;x<cinfo.output_width;x++) {
+ to[x*4 + 0] = 255;
+ to[x*4 + 1] = scanline[x*3 + 0];
+ to[x*4 + 2] = scanline[x*3 + 1];
+ to[x*4 + 3] = scanline[x*3 + 2];
+ }