问题描述
的libjpeg是否允许/有套路缩放输出的图像?
Does libjpeg allows/have routines to scale the output image?
我有需要保存到和加载而来,提供了宽度1,height1输入和输出越来越宽2,身高2时,调整大小的图像,我真的不能外面使用任何东西。
I have an image which needs to be resized when saving to and loading from, Providing width1, height1 on input and getting width2, height2 on output, and I really cant use anything outside.
推荐答案
是的,libjpeg的确实支持图片缩放,但有一些限制。
Yes, libjpeg does support image scaling, but with some limitations.
的libjpeg版本8c和更高支撑的,其中M是1和16之间的整数。更常用的libjpeg版本图6b支持的M 1,第2,第4和8只(即功率为2的降尺度)。
Libjpeg version 8c and higher supports M/8 scaling where M is an integer between 1 and 16. The more commonly used libjpeg version 6b supports M of 1, 2, 4, and 8 only (i.e. power-of-2 downscaling).
供应缩放分子和分母使用scale_num和scale_denom的DECOM pression对象。见jpeg_decom press_struct在jpeglib.h。你可以参考djpeg.c的使用示例。
Supply the scaling numerator and denominator to the decompression object using scale_num and scale_denom. See jpeg_decompress_struct in jpeglib.h. You can refer to djpeg.c for a usage example.
这是更快,并有可能更高质量,比整个图像进行解码,然后按比例缩小。
This is much faster, and potentially higher quality, than decoding the whole image and then downscaling.
这篇关于libjpeg的输出比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!