Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift 2&3: How to Use CGBitmapContextCreate

I have the following code:

let ref:CGContextRef = CGBitmapContextCreate(nil , 200, 130, CGImageGetBitsPerComponent(self.CGImage), 0, CGImageGetColorSpace(self.CGImage), CGImageGetBitmapInfo(self.CGImage))

The problem is that I get this error:

Expression does not conform to type 'NilLieralConvertible'

What should I pass in instead of nil for the first argument and why?

like image 637
zumzum Avatar asked Aug 19 '15 21:08

zumzum


People also ask

What is Swift used for?

Swift is a robust and intuitive programming language created by Apple for building apps for iOS, Mac, Apple TV, and Apple Watch. It's designed to give developers more freedom than ever. Swift is easy to use and open source, so anyone with an idea can create something incredible.

Is Swift programming language easy?

The powerful programming language that is also easy to learn. Swift is a powerful and intuitive programming language for iOS, iPadOS, macOS, tvOS, and watchOS. Writing Swift code is interactive and fun, the syntax is concise yet expressive, and Swift includes modern features developers love.

Is Swift worth learning?

Swift is worth learning in 2022. It's one of the most in-demand and popular languages employers and companies seek. This versatile language is simple to understand. Furthermore, it's the only dynamic language with an integrated development environment specifically designed for iOS development.

When did Swift 5 release?

Swift 5, released in March 2019, introduced a stable binary interface on Apple platforms, allowing the Swift runtime to be incorporated into Apple operating systems. It is source compatible with Swift 4. Swift 5.1 was officially released in September 2019.


1 Answers

The problem is the last argument. Make the last argument CGImageGetBitmapInfo(self.CGImage).rawValue.

like image 69
matt Avatar answered Sep 24 '22 12:09

matt