Skip to content

Switch to using HTMLImageElement #53

@greggman

Description

@greggman

When WebGPU shipped in May 2023 it didn't support loading images from HTMLImageElement. The spec was updated to allow this and Chrome shipped support in v118 so, ... update the examples to use HTMLImageElement

using ImageBitmap is supposedly "better", at least in Chrome, as the idea is that using ImageBitmap is supposed to load the image into the GPU so that when you actually go to use it for uploading into WebGPU (and WebGL) it's ready to use. Further, you can pass in options like "premultiplyAlpha" and "colorSpaceConversion"

Conversely, HTMLImageElement image might not be in a format that can be used immediately and so it forces the browser to re-decode the image, making it slow. For example the HTMLImageElement might use premultiplied alpha which is a lossy format. If you request premultiplyAlpha false, the browser is require to re-decode the image so it is not lossy.

In any case, HTMLImageElement is more common (probably) and the examples should probably be switched to use it? Or maybe just bring it up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions