Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func decodedImage(_ image: UIImage) -> UIImage? {
- guard let newImage = image.cgImage else { return nil }
- let colorSpace = CGColorSpaceCreateDeviceRGB()
- let context = CGContext(data: nil, width: newImage.width, height: newImage.height, bitsPerComponent: 8, bytesPerRow: newImage.width * 4, space: colorSpace, bitmapInfo: CGImageAlphaInfo.noneSkipFirst.rawValue)
- context?.draw(newImage, in: CGRect(x: 0, y: 0, width: newImage.width, height: newImage.height))
- let drawnImage = context?.makeImage()
- if let drawnImage = drawnImage {
- return UIImage(cgImage: drawnImage)
- }
- return nil
- }
Add Comment
Please, Sign In to add comment