ImageBitmap:close() 方法

Baseline 已廣泛支援

此功能已成熟,並可在多種裝置和瀏覽器版本上執行。自 2021 年 9 月起,所有瀏覽器均已支援此功能。

注意:此功能在 Web Workers 中可用。

ImageBitmap.close() 方法會釋放與 ImageBitmap 相關聯的所有圖形資源。

語法

js
close()

引數

無。

返回值

無(undefined)。

示例

js
const offscreen = new OffscreenCanvas(256, 256);
const gl = offscreen.getContext("webgl");

// Perform some drawing using the gl context

const bitmap = offscreen.transferToImageBitmap();
// ImageBitmap { width: 256, height: 256 }

bitmap.close();
// ImageBitmap { width: 0, height: 0 } — disposed

規範

規範
HTML
# dom-imagebitmap-close-dev

瀏覽器相容性

另見