ImageBitmapRenderingContext: transferFromImageBitmap() 方法
注意:此功能在 Web Workers 中可用。
ImageBitmapRenderingContext.transferFromImageBitmap() 方法会将给定的 ImageBitmap 显示在与此渲染上下文关联的画布上。ImageBitmap 的所有权也会转移到画布上。
此方法以前命名为 transferImageBitmap(),但在规范更改中被重命名。为避免代码中断,旧名称被保留为别名。
语法
js
transferFromImageBitmap(bitmap)
参数
bitmap-
要转移的
ImageBitmap对象。
返回值
无(undefined)。
示例
HTML
html
<canvas id="htmlCanvas"></canvas>
JavaScript
js
const htmlCanvas = document
.getElementById("htmlCanvas")
.getContext("bitmaprenderer");
// Draw a WebGL scene offscreen
const offscreen = new OffscreenCanvas(256, 256);
const gl = offscreen.getContext("webgl");
// Perform some drawing using the gl context
// Transfer the current frame to the visible canvas
const bitmap = offscreen.transferToImageBitmap();
htmlCanvas.transferFromImageBitmap(bitmap);
规范
| 规范 |
|---|
| HTML # dom-imagebitmaprenderingcontext-transferfromimagebitmap-dev |
浏览器兼容性
加载中…