// TODO: supports decoding into image.RGBA instead of rgb.Image. func decodeRGB(dinfo *C.struct_jpeg_decompress_struct) (dest *rgb.Image, err error) { C.jpeg_calc_output_dimensions(dinfo) dest = rgb.NewImage(image.Rect(0, 0, int(dinfo.output_width), int(dinfo.output_height))) dinfo.out_color_space = C.JCS_RGB readScanLines(dinfo, dest.Pix, dest.Stride) return }