Have been looking into this topic, and use this method with varying luck:
-(RGBPixel*)bitmap{
CGImageRef cgImage = [image CGImage];
CGDataProviderRef provider = CGImageGetDataProvider(cgImage);
bitmapData = CGDataProviderCopyData(provider);
[self setPixelByteData: malloc( CFDataGetLength(bitmapData) )];
CFDataGetBytes( bitmapData, CFRangeMake( 0, CFDataGetLength( bitmapData ) ), pixelByteData );
pixelData = (RGBPixel*) pixelByteData;
colorLabel.text = [[NSString alloc]initWithFormat:@"Pixel data: red (%i), green (%i), blue (%i).", pixelData[100].red, pixelData[100].green, pixelData[100].blue] ;
return pixelData;
}
The only thing that doesn`t work as I want is the red pixel data: it always says 255, while the green and blue behave as expected. What am I doing wrong?