NativeImage

external class NativeImage(source)

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
external object Companion

Properties

Link copied to clipboard

A boolean property that determines whether the image is considered a template image.

Functions

Link copied to clipboard

Add an image representation for a specific scale factor. This can be used to programmatically add different scale factor representations to an image. This can be called on empty images.

Link copied to clipboard
external fun crop(rect: Rectangle): NativeImage

The cropped image.

Link copied to clipboard
external fun getAspectRatio(scaleFactor: Double = definedExternally): Double

The image's aspect ratio (width divided by height).

Link copied to clipboard
external fun getBitmap(options: BitmapOptions = definedExternally)

Legacy alias for image.toBitmap().

Link copied to clipboard
external fun getNativeHandle(): Buffer<*>

A Buffer that stores C pointer to underlying native handle of the image. On macOS, a pointer to NSImage instance is returned.

Link copied to clipboard

An array of all scale factors corresponding to representations for a given NativeImage.

Link copied to clipboard
external fun getSize(scaleFactor: Double = definedExternally): Size

If scaleFactor is passed, this will return the size corresponding to the image representation most closely matching the passed value.

Link copied to clipboard
external fun isEmpty(): Boolean

Whether the image is empty.

Link copied to clipboard
external fun isTemplateImage(): Boolean

Whether the image is a macOS template image.

Link copied to clipboard
external fun resize(options: ResizeOptions): NativeImage

The resized image.

Link copied to clipboard
external fun setTemplateImage(option: Boolean)

Marks the image as a macOS template image.

Link copied to clipboard
external fun toBitmap(options: ToBitmapOptions = definedExternally): Buffer<*>

A Buffer that contains a copy of the image's raw bitmap pixel data.

Link copied to clipboard
external fun toDataURL(options: ToDataURLOptions = definedExternally): String

The Data URL of the image.

Link copied to clipboard
external fun toJPEG(quality: Double): Buffer<*>

A Buffer that contains the image's JPEG encoded data.

Link copied to clipboard
external fun toPNG(options: ToPNGOptions = definedExternally): Buffer<*>

A Buffer that contains the image's PNG encoded data.