1
votes

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.

1

1 Answers

0
votes

The pointer can still point to the image data even if its type is void. I posted another related topic at: How to pull out the ARGB component from BitmapContext on iPhone?

And the problem had already been solved.