Atoll/DynamicIsland/components/Shelf/Ext+NSImage.swift
2025-07-13 20:26:03 +05:30

19 lines
455 B
Swift

//
// Ext+NSImage.swift
// NotchDrop
//
// Created by 秋星桥 on 2024/7/8.
//
import Cocoa
extension NSImage {
var pngRepresentation: Data {
guard let cgImage = cgImage(forProposedRect: nil, context: nil, hints: nil) else {
return .init()
}
let imageRep = NSBitmapImageRep(cgImage: cgImage)
imageRep.size = size
return imageRep.representation(using: .png, properties: [:]) ?? .init()
}
}