とを使用しRGBAて画面にデータを描画しています。すでに'を作成してそこにデータを配置した場所で(、...)を使用して作成しようとすると、これは問題なく機能します。CGBitmapContextCreateCGContextDrawImagebitmapcontextCGBitmapContextCreatepixelBuffermallocpixelBuffer
ただし、Core Graphicsで独自のメモリを管理したいので、に渡しNULLてからCGBitmapContextCreate、を呼び出して使用するメモリブロックへのポインタを取得し、を使用してバッファを前述のブロックにCGBitmapContextGetDataコピーします。しかし、私は失敗します。以下の私のコードをご覧ください。私が間違っていることについて何か考えはありますか?RGBAmemcpymemcpy
gtx = CGBitmapContextCreate(NULL, screenWidth, screenHeight, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaNoneSkipLast);
void *data = CGBitmapContextGetData(gtx);
memcpy(data, pixelBuffer, area*componentsPerPixel);
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGImageRef image = CGBitmapContextCreateImage(gtx);
CGContextTranslateCTM(currentContext, 0, screenHeight);
CGContextScaleCTM(currentContext, 1.0, -1.0);
CGContextDrawImage(currentContext, currentSubrect, image);