后慢我有代码这样的事情...Buffere写变得CGBitmapContextCreate
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倍。这只发生在iPad设备上,而不是iPhone上。任何人都面临同样的问题?这里发生了什么?
这里是写操作代码,我把这些在环(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;
}
向我们展示您的写入操作的代码部分? – tia 2010-09-29 17:14:42
我用写代码更新了问题。 – Abix 2010-09-29 17:19:41