Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // this is producing an image with a white background, rather than clear. wtf.
- // chromaKeyCFData is BGRA, with background pixels having A==0.
- // cgImage is source image (from a PNG) that I'm punching green pixels out of.
- // colorSpace is cgImage.colorSpace! (ie, force unwrapped)
- guard let chromaKeyDataProvider = CGDataProvider(data: chromaKeyCFData),
- let chromaKeyCGImage = CGImage(width: cgImage.width,
- height: cgImage.height,
- bitsPerComponent: cgImage.bitsPerComponent,
- bitsPerPixel: cgImage.bitsPerPixel,
- bytesPerRow: cgImage.bytesPerRow,
- space: colorSpace,
- bitmapInfo: cgImage.bitmapInfo,
- provider: chromaKeyDataProvider,
- decode: nil,
- shouldInterpolate: false,
- intent: CGColorRenderingIntent.defaultIntent) else { return nil }
- let chromaKeyImage = UIImage(cgImage: chromaKeyCGImage)
- return chromaKeyImage
Advertisement
Add Comment
Please, Sign In to add comment