NewiPad to get RGB values of pixels in the logic is very slow but, iPad1, iPad2 is very fast.. Why?
- (RGB) getTouchAreaPixelRGB: (CGPoint) point
{
NSString * str_BackImageName = @ "butterfly_BG.png";
CGImageRef cgBackImage = CGImageRetain ([UIImage imageNamed: str_BackImageName]. CGImage);
size_t width = CGImageGetWidth (cgBackImage);
size_t height = CGImageGetHeight (cgBackImage);
CGDataProviderRef backProvider = CGImageGetDataProvider (cgBackImage);
CFDataRef backBitmapData = CGDataProviderCopyData (backProvider);
const UInt8 * backData CFDataGetBytePtr (backBitmapData);
RGB rgb;
if ((point.x <width) && (point.y <height))
{
size_t offset = ((width * point.y) + point.x) * 4;
rgb.nRed = backData [offset];
rgb.nGreen = backData [offset +1];
rgb.nBlue = backData [offset +2];
}
return rgb;
}