I'm loading a grayscale png image and I want to access the underlying pixel data. However after I load get the pixel data via CGImageGetDataProvider, the length of the data returned is longer than expected.
CCGDataProviderRef provider = CGDataProviderCreateWithFilename(cStr);
CGImageRef image = CGImageCreateWithPNGDataProvider(provider, NULL, FALSE, kCGRenderingIntentDefault);
mapWidth = CGImageGetWidth(image); mapHeight = CGImageGetHeight(image);
lookupMap = CGDataProviderCopyData(CGImageGetDataProvider(image));
mapWidth comes out to 1804 and mapHeight comes out to 1005. The product of which is 1813020
When I call
CFDataGetLength(lookupMap)
the response is 1833120.
Where are these extra 20100 bytes coming from? Any help here is much appreciated. Am I missing something about the underlying format of the image?
Upon further examination of the CFDataRef I found that if I loop through the buffer, for each row bytes: 0 to 1803 will be correct from my image, and then the next 20 bytes are all zero. So this means that my returned image is actually coming back as a 1824 by 1005 image instead of 1804 by 1005. Still no explanation as to why.