跳到主要內容
Tauri

image

類別

Image

從上到下、以列為主順序的 RGBA 圖像。

繼承自

存取器

rid
取得簽章
get rid(): number
回傳

number

繼承自

Resource.rid

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

方法

close()
close(): Promise<void>

從記憶體中銷毀並清除此資源。 您不應再對此物件呼叫任何方法,並應捨棄對它的任何參考。

回傳

Promise<void>

繼承自

Resource.close

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

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

傳回此圖像的 RGBA 資料,從上到下、以列為主順序。

回傳

Promise<Uint8Array<ArrayBufferLike>>

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

size()
size(): Promise<ImageSize>

傳回此圖像的大小。

回傳

Promise<ImageSize>

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

fromBytes()
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"] }
參數
參數類型
bytesnumber[] | ArrayBuffer | Uint8Array<ArrayBufferLike>
回傳

Promise<Image>

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

fromPath()
static fromPath(path): Promise<Image>

使用提供的路徑建立新圖像。

僅支援 icopng(基於啟用的功能標誌)。

請注意,您需要 image-icoimage-png Cargo 功能才能使用此 API。若要啟用它,請變更您的 Cargo.toml 檔案

[dependencies]
tauri = { version = "...", features = ["...", "image-png"] }
參數
參數類型
pathstring
回傳

Promise<Image>

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

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

使用 RGBA 資料、從上到下以列為主順序,以及指定的寬度和高度來建立新的 Image。

參數
參數類型
rgbanumber[] | ArrayBuffer | Uint8Array<ArrayBufferLike>
widthnumber
heightnumber
回傳

Promise<Image>

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

介面

ImageSize

屬性

屬性類型定義於
heightnumber來源https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/image.ts#L12
widthnumber來源https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/image.ts#L10

函式

transformImage()

function transformImage<T>(image): T

將各種型別的圖像轉換為 Rust 可接受的型別。

有關更多資訊,請參閱 tauri::image::JsImage。請注意,API 簽章不穩定,可能會變更。

類型參數

類型參數
T

參數

參數類型
image| null | string | number[] | ArrayBuffer | Uint8Array<ArrayBufferLike> | Image

回傳

T

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


© 2025 Tauri 貢獻者。CC-BY / MIT