Formatting, linting, and hopefully a CI build.

This commit is contained in:
2023-04-22 15:43:22 -07:00
parent 2759c8d7fb
commit 4bf5ceefbe
13 changed files with 117 additions and 68 deletions

View File

@ -0,0 +1,22 @@
import CoreImage
import Foundation
import UniformTypeIdentifiers
extension CGImage {
func toPngData() throws -> Data {
guard let data = CFDataCreateMutable(nil, 0) else {
throw SdCoreError.imageEncode
}
guard let destination = CGImageDestinationCreateWithData(data, "public.png" as CFString, 1, nil) else {
throw SdCoreError.imageEncode
}
CGImageDestinationAddImage(destination, self, nil)
if CGImageDestinationFinalize(destination) {
return data as Data
} else {
throw SdCoreError.imageEncode
}
}
}