このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docsコミュニティーについてもっと知り、仲間になるにはこちらから。
WorkerGlobalScope: createImageBitmap() メソッド
Baseline Widely available *
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2021年9月.
* Some parts of this feature may have varying levels of support.
メモ: この機能はウェブワーカー内でのみ利用可能です。
createImageBitmap() はWorkerGlobalScope インターフェイスのメソッドで、指定されたソースからビットマップを作成し、オプションでそのソースの一部のみを切り抜きます。このメソッドは、さまざまな画像ソースを受け付け、ImageBitmap に解決するPromise を返します。
In this article
構文
createImageBitmap(image)createImageBitmap(image, options)createImageBitmap(image, sx, sy, sw, sh)createImageBitmap(image, sx, sy, sw, sh, options)引数
image画像ソースで、以下のうちの何れかです。
sxImageBitmapが抽出される長方形の参照点の x 座標。syImageBitmapが抽出される長方形の参照点の y 座標。swImageBitmapが抽出される長方形の幅。この値は負の値にすることができます。shImageBitmapが抽出される長方形の高さ。この値は負の値にすることができます。options省略可画像の抽出のためのオプションを設定するオブジェクト。利用可能なオプションは以下の通りです。
imageOrientationSpecifies how the bitmap image should be oriented.
from-imageEXIF 方向メタデータが存在する場合、その方向に従って画像を表示します(既定値)。
flipYEXIF 方向メタデータが存在する場合、そのメタデータに従って画像の方向を調整し、垂直方向に反転します。
none画像のエンコード方式に従って画像の方向を調整し、方向に関するメタデータ(EXIF メタデータなど、画像を縦向きで撮影するためにカメラを横向きにしたことを示すために画像に追加される場合のあるメタデータ)は無視します。
premultiplyAlphaSpecifies whether the bitmap's color channels should be premultiplied by the alpha channel.One of
none,premultiply, ordefault(default).colorSpaceConversionSpecifies whether the image should be decoded using color space conversion.Either
noneordefault(default).The valuedefaultindicates that implementation-specific behavior is used.resizeWidthA long integer that indicates the output width.
resizeHeightA long integer that indicates the output height.
resizeQualitySpecifies the algorithm to be used for resizing the input to match the output dimensions.One of
pixelated,low(default),medium, orhigh.
返値
指定された長方形のビットマップデータを保持するImageBitmap オブジェクトに解決するPromise を返します。
例
例についてはWindow.createImageBitmap() を参照してください。
仕様書
| Specification |
|---|
| HTML> # dom-createimagebitmap-dev> |