2
我有这样一个通常的代码:libjpeg:如何获得正确的图像解压缩大小?
struct jpeg_decompress_struct cinfo;
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, infile);
jpeg_read_header(&cinfo, TRUE);
cinfo.scale_num = ?;
cinfo.scale_denom = ?;
needed_width = cinfo.output_width;
needed_height = cinfo.output_height;
如何拿起scale_num和scale_denum parametrs缩放图像,以GE需要的尺寸。我想要比例缩小一倍。
如果我设置scale_num = 1
,scale_denom = 2
。其结果是:(1802 X 1237)至(258 X 194)
文档说:
Scale the image by the fraction scale_num/scale_denom. Default is
1/1, or no scaling. Currently, the only supported scaling ratios
are 1/1, 1/2, 1/4, and 1/8.
但是,当我设置这样的比例我没有得到需要的结果。
所以问题是:如何设置scale_num
和scale_denom
到需要得到图像最大尺寸相似。
此代码不会为我工作。 scale_den始终为1. –
什么是您的输入宽度和高度以及needed_width,needed_height? – pogorskiy
3264 x 2448到1024 x 768,结果是1632 x 1224.但是libjpeg可以为这个图像加载例如1224 x 918。 –