Is that possible to read just a small rectangle area of a large image file?
是否可以只读取大图像文件的小矩形区域?
2 个解决方案
#1
5
This is not possible. First of all the iPhone api certainly doesn't support it. More importantly, image formats such as JPEG generally store the pixels row by row, and then apply sequential compression to the entire stream - that means you must start at the beginning and follow through. (not sure about PNG)
这不可能。首先,iPhone api肯定不支持它。更重要的是,JPEG等图像格式通常逐行存储像素,然后对整个流应用顺序压缩 - 这意味着您必须从头开始并完成。 (不确定PNG)
Your best bet, if you need this really bad, for jpeg, is to link against a clone of libjpeg in which you hack some stuff to skip through the Huffman(-ish) encoded 8x8 MCU blocks, and only store the part you need.
你最好的选择,如果你需要这个非常糟糕,对于jpeg,是链接到一个libjpeg的克隆,你在其中破解一些东西来跳过霍夫曼(-ish)编码的8x8 MCU块,并且只存储你需要的部分。
From experience I can tell that the speed gain will be some 70% if you apply a truckload of tricks to skip from one MCU block to the next, without actually decoding them. (I needed only the very first entry of each block for a fast 8-to-1 downscaling)
根据经验,我可以看出,如果你应用一大堆技巧从一个MCU块跳到另一个MCU块,而不实际解码它们,速度增益将达到70%左右。 (我只需要每个块的第一个条目进行快速的8比1缩减)
It would be a very interesting project, but unless you feel a pressing need I would just read in the entire image and then slice out the part you need.
这将是一个非常有趣的项目,但除非您感到迫切需要,否则我只需阅读整个图像,然后切出您需要的部分。
#2
1
Try: CGImageCreateWithImageInRect
#1
5
This is not possible. First of all the iPhone api certainly doesn't support it. More importantly, image formats such as JPEG generally store the pixels row by row, and then apply sequential compression to the entire stream - that means you must start at the beginning and follow through. (not sure about PNG)
这不可能。首先,iPhone api肯定不支持它。更重要的是,JPEG等图像格式通常逐行存储像素,然后对整个流应用顺序压缩 - 这意味着您必须从头开始并完成。 (不确定PNG)
Your best bet, if you need this really bad, for jpeg, is to link against a clone of libjpeg in which you hack some stuff to skip through the Huffman(-ish) encoded 8x8 MCU blocks, and only store the part you need.
你最好的选择,如果你需要这个非常糟糕,对于jpeg,是链接到一个libjpeg的克隆,你在其中破解一些东西来跳过霍夫曼(-ish)编码的8x8 MCU块,并且只存储你需要的部分。
From experience I can tell that the speed gain will be some 70% if you apply a truckload of tricks to skip from one MCU block to the next, without actually decoding them. (I needed only the very first entry of each block for a fast 8-to-1 downscaling)
根据经验,我可以看出,如果你应用一大堆技巧从一个MCU块跳到另一个MCU块,而不实际解码它们,速度增益将达到70%左右。 (我只需要每个块的第一个条目进行快速的8比1缩减)
It would be a very interesting project, but unless you feel a pressing need I would just read in the entire image and then slice out the part you need.
这将是一个非常有趣的项目,但除非您感到迫切需要,否则我只需阅读整个图像,然后切出您需要的部分。
#2
1
Try: CGImageCreateWithImageInRect