我有下一个标准代码的JPEG图像解压缩,这是基于libjpeg。
jpeg_decompress_struct cinfo;
// ...Set error manager and data source...
jpeg_read_header(&cinfo, TRUE);
jpeg_start_decompress(&cinfo);
while (cinfo.output_scanline < cinfo.output_height) {
JSAMPLE* scanlines[1];
// ...Set target pointer for scanline...
jpeg_read_scanlines(&cinfo, scanlines, 1);
}
jpeg_destroy_decompress(&cinfo);我想读图片的一部分,用矩形裁剪:
// struct RECT {
// int left;
// int top;
// int right;
// int bottom;
// };
RECT cropRect; // Coordinates of the crop rectangle relative to the output image size在下面的代码中,我应该修改什么来告诉libjpeg立即裁剪图像?
这就是我如何实现它:
top - 1线;bottom - top行: 1)将扫描线读取到临时缓冲区;2)将列范围[left, right)中的像素从临时缓冲区复制到目标缓冲区。但是这个代码是多余的。
发布于 2012-10-03 17:10:20
就性能而言,特别是如果原始图像是高分辨率的,并且需要相对较小的一部分,那么您应该首先使用裁剪/修剪图像,不需要解压缩。,在16x16px (8x8?)粒度和速度,然后解压缩只跳过几行和像素的边缘。您也可能喜欢这种方法,因为在操作中使用的内存较少。
如果你只是剪裁一点点,那么最初开始完全解压缩的计划也许是最好的。这里几乎没有多余的东西。
https://stackoverflow.com/questions/12712819
复制相似问题