解决GPUImage2 PictureOutput无法输出带透明度图片

GPUImage2 PictureOutput.swift 类中CGImage转UIImage时,bitmapInfo参数传入了默认的CGBitmapInfo(),没有透明通道

return CGImage(width:Int(framebuffer.size.width), height:Int(framebuffer.size.height), bitsPerComponent:8, bitsPerPixel:32, bytesPerRow:4 * Int(framebuffer.size.width), space:defaultRGBColorSpace, bitmapInfo:CGBitmapInfo() /*| CGImageAlphaInfo.Last*/, provider:dataProvider, decode:nil, shouldInterpolate:false, intent:.defaultIntent)!

将其注释中的bitmapInfo取代默认的CGBitmapInfo()即可输出透明度图片

return CGImage(width:Int(framebuffer.size.width), height:Int(framebuffer.size.height), bitsPerComponent:8, bitsPerPixel:32, bytesPerRow:4 * Int(framebuffer.size.width), space:defaultRGBColorSpace, bitmapInfo:CGBitmapInfo(rawValue: CGImageAlphaInfo.last.rawValue) /*| CGImageAlphaInfo.Last*/, provider:dataProvider, decode:nil, shouldInterpolate:false, intent:.defaultIntent)!

相关提交:
https://github.com/liuqiaohong0515/GPUImage2/commit/9790b6aa760f85ed40aed670c72b5c7702322355

相关代码上传到了GPUImage2的一个fork上,可以直接下载使用:
https://github.com/liuqiaohong0515/GPUImage2

© 版权声明
THE END
如果内容对您有所帮助,就支持一下吧!
点赞0 分享
评论 共2条

请登录后发表评论