Namespace: SpawnDev.SpawnJS.JSObjects
Source: JSObjects/ImageBitmapOptions.cs
MDN Reference: ImageBitmapOptions on MDN
An object that sets options for the image's extraction when using Window.CreateImageBitmap https://developer.mozilla.org/en-US/docs/Web/API/Window/createImageBitmap#options
| Property | Type | Access | Description |
|---|---|---|---|
ImageBitmapOptions |
class |
get | An object that sets options for the image's extraction when using Window.CreateImageBitmap https://developer.mozilla.org/en-US/docs/Web/API/Window/createImageBitmap#options |
PremultiplyAlpha |
string? |
get | |
ColorSpaceConversion |
string? |
get | |
ResizeWidth |
int? |
get | |
ResizeHeight |
int? |
get | |
ResizeQuality |
string? |
get |
SpawnDev.SpawnJS Mapping Note: The JavaScript examples below show the standard Web API usage. In SpawnDev.SpawnJS, the same API is available with C# conventions:
- Properties and methods use PascalCase (e.g.,
readyStatebecomesReadyState)- Events use ActionEvent with
+=/-=(e.g.,addEventListener("click", fn)becomesOnClick += handler)- Async methods return
Task<T>instead ofPromise<T>- Objects should be disposed with
usingstatements- Access via
JS.Get<ImageBitmapOptions>(...)or constructornew ImageBitmapOptions(...)
const canvas = document.getElementById("myCanvas"),
ctx = canvas.getContext("2d"),
image = new Image();
// Wait for the sprite sheet to load
image.onload = () => {
Promise.all([
// Cut out two sprites from the sprite sheet
createImageBitmap(image, 0, 0, 32, 32),
createImageBitmap(image, 32, 0, 32, 32),
createImageBitmap(image, 0, 0, 50, 50, { imageOrientation: "flipY" }),
]).then((sprites) => {
// Draw each sprite onto the canvas
ctx.drawImage(sprites[0], 0, 0);
ctx.drawImage(sprites[1], 32, 32);
ctx.drawImage(sprites[2], 64, 64);
});
};
// Load the sprite sheet from an image file
image.src = "50x50.jpg";