views:

154

answers:

2

The doc is mentioning an CGBitmapContextGetBitsPerPixel(). I am almost sure that I would just have to divide this by 8.

But since I didnt study computer science, I am confused about the detail. Would it make a difference if it's an 8 bit PNG or 24 bit PNG? Or some other PNG?

So to get securely the bytes per pixel of an CGContextRef, would I just devide by 8?

+1  A: 

you are right

CiNN
+2  A: 

The number of bits per pixel may not necessarily be a multiple of 8. 15-bit is sometimes used, as is 1-bit for black-and-white images. So if you want to find the minimum number of bytes required to hold the value for a single pixel, divide by 8 and round up.

Chris Thornhill