All Downloads are FREE. Search and download functionalities are using the official Maven repository.

macosMain.com.seiko.imageloader.util.NSImageExt.kt Maven / Gradle / Ivy

There is a newer version: 1.8.3
Show newest version
package com.seiko.imageloader.util

import kotlinx.cinterop.ExperimentalForeignApi
import org.jetbrains.skia.Image
import platform.AppKit.NSImage
import platform.CoreGraphics.CGImageRef

@OptIn(ExperimentalForeignApi::class)
fun NSImage.toSkiaImage(): Image {
    val cgImage: CGImageRef = this.CGImageForProposedRect(
        proposedDestRect = null,
        context = null,
        hints = null,
    ) ?: throw IllegalArgumentException("can't read CGImage of $this")
    return cgImage.toSkiaImage()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy