Since apple announced the new display I have been interested about how to use Core Graphics to create images to profit this display. Does anyone know how to do it or has been any documentation launched?
bitsPerComponent supports up to 8 bits
https://developer.apple.com/documentation/coregraphics/cgimage/1454980-bitspercomponent
This is the function that I use to convert data to image:
Thanks!
bitsPerComponent supports up to 8 bits
https://developer.apple.com/documentation/coregraphics/cgimage/1454980-bitspercomponent
This is the function that I use to convert data to image:
Code Block language static func data2Image(inputData: [UInt32], width: Int, height: Int) -> UIImage? { let rgbColorSpace = CGColorSpaceCreateDeviceRGB() let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedFirst.rawValue) let bitsPerComponent = 8 let bitsPerPixel = 32 var data = inputData let cgim = data.withUnsafeMutableBytes { (ptr) -> CGImage in let ctx = CGContext( data: ptr.baseAddress, width: width, height: height, bitsPerComponent: bitsPerComponent, bytesPerRow: 4*width, space: rgbColorSpace, bitmapInfo: CGBitmapInfo.byteOrder32Little.rawValue + CGImageAlphaInfo.premultipliedLast.rawValue )! return ctx.makeImage()! } return UIImage(cgImage: cgim, scale: UIScreen.main.scale, orientation: .up) }
Thanks!