NewiPad はロジックでピクセルの RGB 値を取得するのが非常に遅いのですが、iPad1、iPad2 は非常に高速です。
- (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;
}