Length of data returned from CGImageGetDataProvider is larger than expected

Posted by jcoplan on Stack Overflow See other posts from Stack Overflow or by jcoplan
Published on 2010-05-20T04:35:04Z Indexed on 2010/05/20 4:40 UTC
Read the original article Hit count: 222

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about iphone-sdk-3.0

Related posts about images