mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 23:24:32 +00:00
19 lines
455 B
Swift
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()
|
|
}
|
|
}
|