CGImageRef width doesn't agree with bytes-per-row

旧城冷巷雨未停 提交于 2019-12-04 07:08:03

The bytes per row (also called the “stride”) can be larger than the width of the image. The extra bytes at the end of each row are simply ignored. The bytes for the pixel at (x, y) start at offset y * bpr + x * bpp (where bpr is bytes-per-row and bpp is bytes-per-pixel).

Notice that 1376 is exactly divisible by 32 (and all smaller powers of 2), while 1366 is not. The CPUs in modern Macs have instructions that operate on 16 or 32 or 64 bytes at a time, so the CGImage algorithms can be more efficient if the image's stride is a multiple of 16 or 32 or 64. CGDisplayCreateImage was written by someone who knows this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!