views:

122

answers:

1

I'm working on obtaining bitmap data like ARGB from an image.

a). I create a bitmapcontext for the image:

context = CGBitmapContextCreate(void * data, size_t width, size_t height, size_t bitsPerComponent, size_t bytesPerRow, CGColorSpaceRef colorspace, CGBitmapInfo bitmapInfo)

b). I draw the image to the context:

CGContextDrawImage(context, rect, imageRef);

c). Then I get data from the bitmapcontext:

void * data = CGBitmapContextGetData(context);

d). void... not readable?

I find that it only returns a void pointer to the image context data which means the data of the context cannot be obtained(writeOnly). Are there any other ways to return the value from the context data?

PS: If I create an unsigned char pointer * data, it will return 240 for RGB and 255 for alpha which are not the correct color components.

A: 

The pointer can still point to the image data even if its type is void. I posted another related topic at: http://stackoverflow.com/questions/561663/how-to-pull-out-the-argb-component-from-bitmapcontext-on-iphone

And the problem had already been solved.

iPhoney