Skip to content

image

Classes

Image

An RGBA Image in row-major order from top to bottom.

Extends

Accessors

rid
Get Signature
get rid(): number
Returns

number

Inherited from

Resource.rid

Methods

close()
close(): Promise<void>

Destroys and cleans up this resource from memory. You should not call any method on this object anymore and should drop any reference to it.

Returns

Promise<void>

Inherited from

Resource.close

rgba()
rgba(): Promise<Uint8Array<ArrayBufferLike>>

Returns the RGBA data for this image, in row-major order from top to bottom.

Returns

Promise<Uint8Array<ArrayBufferLike>>

size()
size(): Promise<ImageSize>

Returns the size of this image.

Returns

Promise<ImageSize>

fromBytes()
static fromBytes(bytes): Promise<Image>

Creates a new image using the provided bytes by inferring the file format. If the format is known, prefer [@link Image.fromPngBytes] or [@link Image.fromIcoBytes].

Only ico and png are supported.

###### Parameters
| Parameter | Type |
| ------ | ------ |
| `bytes` | `number`[] \| [`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) \| [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)\<`ArrayBufferLike`\> |
###### Returns
[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`Image`](/taurify/api/namespaceimage/#image)\>
<a id="frompath" name="frompath"></a>
##### fromPath()
```ts
static fromPath(path): Promise<Image>

Creates a new image using the provided path.

Only ico and png are supported.

###### Parameters
| Parameter | Type |
| ------ | ------ |
| `path` | `string` |
###### Returns
[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`Image`](/taurify/api/namespaceimage/#image)\>
<a id="new" name="new"></a>
##### new()
```ts
static new(
rgba,
width,
height): Promise<Image>

Creates a new Image using RGBA data, in row-major order from top to bottom, and with specified width and height.

Parameters
ParameterType
rgbanumber[] | ArrayBuffer | Uint8Array<ArrayBufferLike>
widthnumber
heightnumber
Returns

Promise<Image>

Interfaces

ImageSize

Properties

PropertyTypeDefined in
heightnumber
widthnumber

Functions

transformImage()

function transformImage<T>(image): T

Transforms image from various types into a type acceptable by Rust.

See tauri::image::JsImage for more information. Note the API signature is not stable and might change.

Type Parameters

Type Parameter
T

Parameters

ParameterType
image| null | string | number[] | ArrayBuffer | Uint8Array<ArrayBufferLike> | Image

Returns

T