turbo jpeg 解码缩小图片出错
turbo jpeg 解码图片,缩小到原图的1/64时出错,提示:
tjDecompress2(): Could not scale down to desired image dimensions
什么原因?原图大小为3264*2448
int image_width, image_height, subsample;
int result = tjDecompressHeader2(handle, jpeg_buffer, jpeg_size,
&image_width, &image_height, &subsample);
LOG_D("image_width %d , image_height %d , subsample %d ", image_width, image_height, subsample);
int scale = sampleSize;
tjscalingfactor sf;
sf.num = 1;
sf.denom = sampleSize;
image_width = TJSCALED(image_width, sf);
image_height = TJSCALED(image_height, sf);
LOG_D("after scale, image_width %d , image_height %d", image_width, image_height);
int stride = image_width * 4;
unsigned char* out_buffer = (unsigned char*)malloc(stride * image_height);
int flags = 0;
flags |= 0;
int pixelfmt = TJPF_RGBA;
bool decompress = tjDecompress2(handle, jpeg_buffer, jpeg_size, out_buffer, image_width, 0,
image_height, pixelfmt, flags);
if (decompress) {
LOG_E("decompress fail %s\n", tjGetErrorStr());
}
tjDestroy(handle);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论