美文网首页
解决GPUImage2 PictureOutput无法输出带透明

解决GPUImage2 PictureOutput无法输出带透明

作者: 刘乔泓 | 来源:发表于2022-03-16 11:53 被阅读0次

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

相关文章

网友评论

      本文标题:解决GPUImage2 PictureOutput无法输出带透明

      本文链接:https://www.haomeiwen.com/subject/gmhpdrtx.html