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