TL/DR: How to convert Uint8ClampedArray
with RGBA values to an image without using DOM
(canvas
element) or OffscreenCanvas
?
I'm looking for a way to convert a Uint8ClampedArray
object, which holds RGBA values, to a valid Blob
object or a Blob
URL using URL.createObjectURL
for data which was created by the blurhash
or fast-blurhash
packages, with the restriction of not being able to use the DOM
(canvas
, etc.) or OffscreenCanvas
.
The blurhash
library converts a "blurhash" to a Uint8ClampedArray
object, holding RGBA values, which then can be used to render a placeholder image; most often by using a canvas
element.
In my case I'd like to create a viewable in-browser image from the Uint8ClampedArray
object without using DOM
-related functions or OffscreenCanvas
.
Is there any way to convert the given Uint8ClampedArray
data to a viewable image using Blob
, a Blob
URL or any other browser-native functionality without using canvas
?
Thanks a lot!