CGContextDrawImage は非常にコストがかかる可能性があるため、ピクセル データを調べる間、与えるデータの量を最小限に抑えようとしています。2 つの画像とその交点の CGRect がある場合、CGContextDrawImage を取得して、それぞれの交点のみを個別に描画することはできますか (その結果、画像の 1 つの交点を含む 2 つの CGContextRef が生成されます)。
動作しないコードがいくつかありますが、1 つの画像に必要なものに近いはずです...
CGImageRef imageRef = [image CGImage];
NSUInteger width = rectIntersect.size.width;
NSUInteger height = rectIntersect.size.height;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
unsigned char *rawData = (unsigned char*) calloc(height * width * 4, sizeof(unsigned char));
NSUInteger bytesPerPixel = 4;
NSUInteger bytesPerRow = bytesPerPixel * width;
NSUInteger bitsPerComponent = 8;
CGContextRef context = CGBitmapContextCreate(rawData, width, height,
bitsPerComponent, bytesPerRow, colorSpace,
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGColorSpaceRelease(colorSpace);
// rectIntersect down here contains the intersection of the two images...
CGContextDrawImage(context, rectIntersect, imageRef);