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

浏览器兼容性

另见