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
urlsource URL
Return Value
optional CGImage
-
Create CGImage from data
Declaration
Swift
static func imageFrom(data: Data) -> CGImage?Parameters
datasource data
Return Value
optional CGImage
-
Write out a png
Declaration
Swift
func writePNG(to: URL) -> BoolParameters
todestination 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
sizesize of resulting image
fromRectsource rect (does not need to be within the image)
hasAlphawhether the result should have an alpha channel
backgroundColourif the image doesn’t have an alpha channel, then this fill is applied ‘behind’ the image
Return Value
optional CGImage
CGImage Extension Reference