--- title: OffscreenCanvas.transferToImageBitmap() slug: Web/API/OffscreenCanvas/transferToImageBitmap translation_of: Web/API/OffscreenCanvas/transferToImageBitmap ---
{{APIRef("Canvas API")}} {{SeeCompatTable}}

OffscreenCanvas.transferToImageBitmap() 方法使用offscreenCanvas最近渲染得到的图片创建一个{{domxref("ImageBitmap")}} 对象.

语法

ImageBitmap OffscreenCanvas.transferToImageBitmap()

返回值

一个{{domxref("ImageBitmap")}}对象.

例子

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

//一些绘制要使用gl前后文

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

Specifications

Specification Status Comment
{{SpecName('HTML WHATWG', "#dom-offscreencanvas-transfertoimagebitmap", "OffscreenCanvas.transferToImageBitmap()")}} {{Spec2('HTML WHATWG')}}

浏览器兼容

{{Compat("api.OffscreenCanvas.transferToImageBitmap")}}

浏览相关