Begin statistics creation

This commit is contained in:
Christoph Hagen
2025-08-31 16:27:32 +02:00
parent f972a2c020
commit 96bd07bdb7
33 changed files with 1406 additions and 187 deletions

View File

@@ -0,0 +1,28 @@
import AppKit
extension NSImage {
func writePng(to url: URL) -> Bool {
// Get CGImage from NSImage
guard let cgImage = self.cgImage(forProposedRect: nil, context: nil, hints: nil) else {
return false
}
// Create a bitmap representation
let bitmapRep = NSBitmapImageRep(cgImage: cgImage)
bitmapRep.size = self.size // Preserve image size
// Convert to PNG data
guard let pngData = bitmapRep.representation(using: .png, properties: [:]) else {
return false
}
do {
try pngData.write(to: url)
return true
} catch {
print("Error writing PNG:", error)
return false
}
}
}