私はこのようなコードを持っています...
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef ctx = CGBitmapContextCreate(pixelArray, width, height, 8, 4 * width, colorSpace, kCGImageAlphaNoneSkipLast);
CGImageRef createdImage = CGBitmapContextCreateImage (ctx);
uiImage = [[UIImage imageWithCGImage:createdImage] retain];
問題は、バッファー (pixelArray) から CGImage と UIImage を作成すると、バッファーへの書き込み操作が少なくとも 4 倍遅くなることです。これは、iPhone ではなく iPad デバイスでのみ発生します。誰かが同じ問題に直面していますか?ここで何が起こっているのですか?
これが書き込み操作コードで、これらをループで呼び出します (setPixel)...
- (RGBA*) getPixel:(NSInteger)x y:(NSInteger)y {
// Bound the co-cordinates.
x = MIN(MAX(x, 0), width - 1);
y = MIN(MAX(y, 0), height - 1);
// yIndexes are pre populated
return (RGBA*)(&pixelArray[(x + yIndexes[y]) << 2]);
}
- (void) setPixel:(RGBA*)color x:(NSInteger)x y:(NSInteger)y {
// Bound the co-cordinates.
x = MIN(MAX(x, 0), _width);
y = MIN(MAX(y, 0), _height);
memcpy([self getPixel:x y:y], color, 3);
colorDirtyBit = YES;
}