XCode 13.4.1
Swift 5
Examined towards iPhone simulators 11,13
I am making an attempt to grasp why within the following operate ctx.makeImage() returns a sound picture within the playground however a 0 within the simulator. I am assuming it is one thing within the arguments to makeImage() however I am darned if I can determine what it’s. Any recommendations shall be gratefully acquired.
func loadImage() -> CGImage? {
var srgbArray = [UInt32](repeating: 0xFF204080, rely: 512*512)
_ = srgbArray.withUnsafeMutableBytes { (ptr) -> CGImage? in
let ctx = CGContext(
knowledge: ptr.baseAddress,
width: 512,
peak: 512,
bitsPerComponent: 8,
bytesPerRow: 4*512,
house: CGColorSpace(identify: CGColorSpace.sRGB)!,
bitmapInfo: CGBitmapInfo.byteOrder32Little.rawValue +
CGImageAlphaInfo.premultipliedFirst.rawValue
)!
let cgImage = ctx.makeImage()
print("cgImage", cgImage)
return(nil)
}
return(nil)
}