The "barbershop pole type pattern" is a classic sign of having the wrong number of bytes per row of pixel data.
You should base wpl
on the value returned by CGImageGetBytesPerRow
. Most likely:
myPix->wpl = CGImageGetBytesPerRow(myCGImage) / 4;
There are several reasons why the image's bytes-per-row would differ from your guess based on CGImageGetWidth()
. For instance, it might be rounded up for performance reasons, or the image might be a sub-image of a wider image.