CGImage
public extension CGImage
-
Image size
Declaration
Swift
var size: CGSize { get }
-
Create CGImage from url
Declaration
Swift
static func imageFrom(url: URL) -> CGImage?
Parameters
url
source URL
Return Value
optional CGImage
-
Create CGImage from data
Declaration
Swift
static func imageFrom(data: Data) -> CGImage?
Parameters
data
source data
Return Value
optional CGImage
-
Write out a png
Declaration
Swift
func writePNG(to: URL) -> Bool
Parameters
to
destination fileURL
Return Value
success
-
Png data
Declaration
Swift
func pngData() -> Data?
Return Value
png
-
Make image from all or part of self
Declaration
Swift
func makeImage(size: CGSize, fromRect: CGRect? = nil, hasAlpha: Bool = true, backgroundColour: CGColor = .white) -> CGImage?
Parameters
size
size of resulting image
fromRect
source rect (does not need to be within the image)
hasAlpha
whether the result should have an alpha channel
backgroundColour
if the image doesn’t have an alpha channel, then this fill is applied ‘behind’ the image
Return Value
optional CGImage