跳到内容
Tauri

image

一个按行主序自上而下的 RGBA 图像。

get rid(): number

数字

Resource.rid

来源: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L309

close(): Promise<void>

销毁并从内存中清理此资源。您不应再对此对象调用任何方法,并应放弃对它的任何引用。

Promise<void>

Resource.close

来源: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L321

rgba(): Promise<Uint8Array>

返回此图像的 RGBA 数据,按行主序自上而下。

Promise<Uint8Array>

来源: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/image.ts#L89

size(): Promise<ImageSize>

返回此图像的大小。

Promise<ImageSize>

来源: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/image.ts#L96

static fromBytes(bytes): Promise<Image>

通过推断文件格式,使用提供的字节创建新图像。如果已知格式,则优先使用 [@link Image.fromPngBytes] 或 [@link Image.fromIcoBytes]。

仅支持 icopng(取决于激活的功能标志)。

请注意,您需要 image-icoimage-png Cargo 功能才能使用此 API。要启用它,请更改您的 Cargo.toml 文件

[dependencies]
tauri = { version = "...", features = ["...", "image-png"] }
参数类型
字节Uint8Array | number[] | ArrayBuffer

Promise<Image>

来源: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/image.ts#L62

static fromPath(path): Promise<Image>

使用提供的路径创建新图像。

仅支持 icopng(取决于激活的功能标志)。

请注意,您需要 image-icoimage-png Cargo 功能才能使用此 API。要启用它,请更改您的 Cargo.toml 文件

[dependencies]
tauri = { version = "...", features = ["...", "image-png"] }
参数类型
path字符串

Promise<Image>

来源: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/image.ts#L82

static new(
rgba,
width,
height): Promise<Image>

使用 RGBA 数据(按行主序自上而下)以及指定的宽度和高度创建新图像。

参数类型
rgbaUint8Array | number[] | ArrayBuffer
宽度数字
高度数字

Promise<Image>

来源: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/image.ts#L37

属性类型定义于
height数字来源: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/image.ts#L13
width数字来源: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/image.ts#L11

type MenuIcon:
| NativeIcon
| string
| Image
| Uint8Array
| ArrayBuffer
| number[];

一种表示可在菜单项中使用的图标的类型。

来源: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/image.ts#L17

function transformImage<T>(image): T

将图像从各种类型转换为 Rust 可接受的类型。

有关更多信息,请参阅 tauri::image::JsImage。请注意,API 签名不稳定,可能会更改。

类型参数
T
参数类型
image| null | string | Uint8Array | number[] | ArrayBuffer | Image

T

来源: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/image.ts#L107


© 2025 Tauri 贡献者。CC-BY / MIT