GPUImage icon indicating copy to clipboard operation
GPUImage copied to clipboard

imageFromCurrentlyProcessedOutputWithOrientation not setting CGBitmapInfo correctly?

Open peterhwong opened this issue 14 years ago • 2 comments

Hi Brad, The problem I'm having is described in Issue #321.

Based on reading this link: http://stackoverflow.com/questions/6861891/how-do-you-generate-an-rgba-image-in-core-graphics

I made this change in imageFromCurrentlyProcessedOutputWithOrientation that fixed my problem(else condition, changed : kCGBitmapByteOrderDefault | kCGImageAlphaLast --> kCGImageAlphaPremultipliedLast)

From: if ([GPUImageOpenGLESContext supportsFastTextureUpload] && preparedToCaptureImage) { cgImageFromBytes = CGImageCreate((int)currentFBOSize.width, (int)currentFBOSize.height, 8, 32, CVPixelBufferGetBytesPerRow(renderTarget), defaultRGBColorSpace, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst, dataProvider, NULL, NO, kCGRenderingIntentDefault); } else { cgImageFromBytes = CGImageCreate((int)currentFBOSize.width, (int)currentFBOSize.height, 8, 32, 4 * (int)currentFBOSize.width, defaultRGBColorSpace, kCGBitmapByteOrderDefault | kCGImageAlphaLast, dataProvider, NULL, NO, kCGRenderingIntentDefault); }

To:

if ([GPUImageOpenGLESContext supportsFastTextureUpload] && preparedToCaptureImage) 
{
    cgImageFromBytes = CGImageCreate((int)currentFBOSize.width, (int)currentFBOSize.height, 8, 32, CVPixelBufferGetBytesPerRow(renderTarget), defaultRGBColorSpace, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst, dataProvider, NULL, NO, kCGRenderingIntentDefault);
}
else
{
    cgImageFromBytes = CGImageCreate((int)currentFBOSize.width, (int)currentFBOSize.height, 8, 32, 4 * (int)currentFBOSize.width, defaultRGBColorSpace, kCGImageAlphaPremultipliedLast, dataProvider, NULL, NO, kCGRenderingIntentDefault);
}

What do you think?

Thanks Peter

peterhwong avatar Aug 08 '12 19:08 peterhwong

That might address the case you encountered when shutting off the texture caches, but it doesn't help with the primary case reported in that issue. Still, I'll check this out and if it doesn't have any odd side effects, I'll roll this into the capture code.

BradLarson avatar Aug 08 '12 19:08 BradLarson

Yes, this doesn't address the artifacts issue. Thanks for looking into it.

peterhwong avatar Aug 08 '12 19:08 peterhwong