【发布时间】:2012-10-18 14:53:27
【问题描述】:
我有这么一个常用的代码:
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 参数以将图像缩放到所需的大小。例如,我想将它缩小一倍。
如果我设置 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 以获得与所需最大相似尺寸的图像。
【问题讨论】:
标签: c++ jpeg compression libjpeg