後慢我有代碼這樣的事情...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