Class

Float16Image

Float16ImageFloat16Image(width, height, colorspaceopt, pixelFormatopt)

Represents an image using a Float16Array for its pixel data, providing support for high dynamic range (HDR) color spaces.

Constructor

# new Float16Image(width, height, colorspaceopt, pixelFormatopt)

Creates a new Float16Image instance.

Parameters:
Name Type Attributes Description
width number

The width of the image in pixels.

height number

The height of the image in pixels.

colorspace string <optional>

The color space to use for the image. Defaults to HDRImage.DEFAULT_COLORSPACE.

pixelFormat string <optional>

The pixel format to use for the image. Defaults to DEFAULT_PIXELFORMAT.

View Source src/Float16Image.ts, line 10

Classes

Float16Image
Float16Image
Float16Image
Float16Image

Members

# DEFAULT_PIXELFORMAT

The default pixel format for new images, set to "rgba-float16".

View Source src/Float16Image.ts, line 14

# DEFAULT_PIXELFORMAT

The default pixel format for new images, set to "rgba-float16".

View Source src/Float16Image.ts, line 14

# colorSpace

The color space of the image.

View Source src/Float16Image.ts, line 16

HDRPredefinedColorSpace

# colorSpace

The color space of the image.

View Source src/Float16Image.ts, line 291

# colorSpace

The color space of the image.

View Source src/Float16Image.ts, line 16

HDRPredefinedColorSpace

# colorSpace

The color space of the image.

View Source src/Float16Image.ts, line 291

# data

The raw pixel data stored as a Float16Array.

View Source src/Float16Image.ts, line 12

Float16Array

# data

The raw pixel data stored as a Float16Array.

View Source src/Float16Image.ts, line 283

# data

The raw pixel data stored as a Float16Array.

View Source src/Float16Image.ts, line 12

Float16Array

# data

The raw pixel data stored as a Float16Array.

View Source src/Float16Image.ts, line 283

# pixelFormat

The pixel format of the image - usualy 'rgba-float16'.

View Source src/Float16Image.ts, line 18

ImageDataPixelFormat

# pixelFormat

The pixel format of the image - usualy 'rgba-float16'.

View Source src/Float16Image.ts, line 295

# pixelFormat

The pixel format of the image - usualy 'rgba-float16'.

View Source src/Float16Image.ts, line 18

ImageDataPixelFormat

# pixelFormat

The pixel format of the image - usualy 'rgba-float16'.

View Source src/Float16Image.ts, line 295

ImageDataPixelFormat

# static DEFAULT_PIXELFORMAT

The default pixel format for new images, set to "rgba-float16".

View Source src/Float16Image.ts, line 287

ImageDataPixelFormat

# static DEFAULT_PIXELFORMAT

The default pixel format for new images, set to "rgba-float16".

View Source src/Float16Image.ts, line 287

Methods

# applyGain(gain, optionsopt) → {this}

Scales RGB channels into the HDR range by a gain factor. This is the lightweight replacement for the removed colorjs.io based convertPixelToRec2100_hlg: no gamut conversion, just a linear boost. Values >1 only become visible as HDR on a canvas configured with toneMapping: { mode: "extended" } (see getHdrOptions()), otherwise they clip to SDR white.

Alpha is preserved by default.

When WASM acceleration is enabled via setWasmEnabled(true) (experimental, disabled by default) and the image is large enough, the loop runs in the inlined WASM kernel with transparent fallback to JS.

Parameters:
Name Type Attributes Default Description
gain number | Array.<number>

Uniform gain or per-channel [r, g, b] gain. E.g. 2 doubles brightness into HDR headroom, 0.5 dims to half.

options object <optional>

Options.

preserveAlpha boolean <optional>
true

Leave alpha untouched when true.

useWasm boolean <optional>

Force the WASM (true) or JS (false) path for this call. Defaults to the global flag from setWasmEnabled().

View Source src/Float16Image.ts, line 348

The Float16Image instance for method chaining.

this

# fill(color) → {Float16Image|undefined}

Fills the entire image with a single color.

Parameters:
Name Type Description
color Array.<number>

An array of four numbers representing the R, G, B, and A channels as float values. 0-1 is the SDR range, values >1 push into the HDR headroom (requires an HDR canvas with extended tone mapping to become visible).

View Source src/Float16Image.ts, line 316

The Float16Image instance for method chaining, or undefined if the color array is invalid.

Float16Image | undefined

# getImageData() → {ImageData|null}

Creates a standard ImageData object from the Float16Image data.

View Source src/Float16Image.ts, line 364

An ImageData object, or null if the data is undefined.

ImageData | null

# pixelCallback(fn)

Iterates through each pixel of the image and applies a callback function to its data.

Parameters:
Name Type Description
fn HDRPixelCallback

The callback function to apply to each pixel.

View Source src/Float16Image.ts, line 380

# scaled(gain, optionsopt) → {Float16Image}

Returns a copy of the image with applyGain() applied, leaving the original untouched.

Parameters:
Name Type Attributes Description
gain number | Array.<number>

Uniform gain or per-channel [r, g, b] gain.

options object <optional>

Options, see applyGain().

View Source src/Float16Image.ts, line 357

A new Float16Image with scaled RGB values.

Float16Image

# setImageData(imageData) → {void}

Sets the image data of the current Float16Image instance.

Parameters:
Name Type Description
imageData HDRImageData

The image data to set.

View Source src/Float16Image.ts, line 418

If the color space of the HDRImageData is not supported.

Error
void

# static convertArrayToRec2100_hlg(data) → {Float16Array}

Converts a Uint8ClampedArray of sRGB pixel data to a Float16Array of pixels in the rec2100-hlg color space.

Parameters:
Name Type Description
data Uint8ClampedArray

The array of 8-bit pixel data.

View Source src/Float16Image.ts, line 373

The converted 16-bit pixel data.

Float16Array

# static fromImageData(imageData) → {Float16Image}

Creates a Float16Image instance from an HDRImageData object.

Parameters:
Name Type Description
imageData HDRImageData

The image data to use.

View Source src/Float16Image.ts, line 389

If the color space of the HDRImageData is not supported.

Error

The new Float16Image instance.

Float16Image

# static fromImageDataArray(width, height, imageData) → {Float16Image}

Creates a Float16Image instance from an Uint8ClampedArray object.

Parameters:
Name Type Description
width number

The width of the image.

height number

The height of the image.

imageData HDRImageData

The image data to use.

View Source src/Float16Image.ts, line 400

If the color space of the HDRImageData is not supported.

Error

The new Float16Image instance.

Float16Image

# async static fromURL(url) → {Promise.<(Float16Image|undefined)>}

Loads an image from a URL and creates a Float16Image instance from it.

Parameters:
Name Type Description
url URL

The URL of the image to load.

View Source src/Float16Image.ts, line 409

A promise that resolves with a Float16Image instance, or undefined if the image could not be loaded.

Promise.<(Float16Image|undefined)>

# static scaleUint8ToFloat16(val) → {number}

Scales an 8-bit value to a 16-bit value. This is typically used for the alpha channel.

Parameters:
Name Type Description
val number

The 8-bit value to scale (0-255).

View Source src/Float16Image.ts, line 324

The corresponding 16-bit value.

number

Float16Image(width, height, colorspaceopt, pixelFormatopt)

Represents an image using a Float16Array for its pixel data, providing support for high dynamic range (HDR) color spaces.

Constructor

# new Float16Image(width, height, colorspaceopt, pixelFormatopt)

Creates a new Float16Image instance.

Parameters:
Name Type Attributes Description
width number

The width of the image in pixels.

height number

The height of the image in pixels.

colorspace string <optional>

The color space to use for the image. Defaults to HDRImage.DEFAULT_COLORSPACE.

pixelFormat string <optional>

The pixel format to use for the image. Defaults to DEFAULT_PIXELFORMAT.

View Source src/Float16Image.ts, line 10

Classes

Float16Image
Float16Image
Float16Image
Float16Image

Members

# DEFAULT_PIXELFORMAT

The default pixel format for new images, set to "rgba-float16".

View Source src/Float16Image.ts, line 14

# DEFAULT_PIXELFORMAT

The default pixel format for new images, set to "rgba-float16".

View Source src/Float16Image.ts, line 14

# colorSpace

The color space of the image.

View Source src/Float16Image.ts, line 16

HDRPredefinedColorSpace

# colorSpace

The color space of the image.

View Source src/Float16Image.ts, line 291

# colorSpace

The color space of the image.

View Source src/Float16Image.ts, line 16

HDRPredefinedColorSpace

# colorSpace

The color space of the image.

View Source src/Float16Image.ts, line 291

# data

The raw pixel data stored as a Float16Array.

View Source src/Float16Image.ts, line 12

Float16Array

# data

The raw pixel data stored as a Float16Array.

View Source src/Float16Image.ts, line 283

# data

The raw pixel data stored as a Float16Array.

View Source src/Float16Image.ts, line 12

Float16Array

# data

The raw pixel data stored as a Float16Array.

View Source src/Float16Image.ts, line 283

# pixelFormat

The pixel format of the image - usualy 'rgba-float16'.

View Source src/Float16Image.ts, line 18

ImageDataPixelFormat

# pixelFormat

The pixel format of the image - usualy 'rgba-float16'.

View Source src/Float16Image.ts, line 295

# pixelFormat

The pixel format of the image - usualy 'rgba-float16'.

View Source src/Float16Image.ts, line 18

ImageDataPixelFormat

# pixelFormat

The pixel format of the image - usualy 'rgba-float16'.

View Source src/Float16Image.ts, line 295

ImageDataPixelFormat

# static DEFAULT_PIXELFORMAT

The default pixel format for new images, set to "rgba-float16".

View Source src/Float16Image.ts, line 287

ImageDataPixelFormat

# static DEFAULT_PIXELFORMAT

The default pixel format for new images, set to "rgba-float16".

View Source src/Float16Image.ts, line 287

Methods

# applyGain(gain, optionsopt) → {this}

Scales RGB channels into the HDR range by a gain factor. This is the lightweight replacement for the removed colorjs.io based convertPixelToRec2100_hlg: no gamut conversion, just a linear boost. Values >1 only become visible as HDR on a canvas configured with toneMapping: { mode: "extended" } (see getHdrOptions()), otherwise they clip to SDR white.

Alpha is preserved by default.

When WASM acceleration is enabled via setWasmEnabled(true) (experimental, disabled by default) and the image is large enough, the loop runs in the inlined WASM kernel with transparent fallback to JS.

Parameters:
Name Type Attributes Default Description
gain number | Array.<number>

Uniform gain or per-channel [r, g, b] gain. E.g. 2 doubles brightness into HDR headroom, 0.5 dims to half.

options object <optional>

Options.

preserveAlpha boolean <optional>
true

Leave alpha untouched when true.

useWasm boolean <optional>

Force the WASM (true) or JS (false) path for this call. Defaults to the global flag from setWasmEnabled().

View Source src/Float16Image.ts, line 348

The Float16Image instance for method chaining.

this

# fill(color) → {Float16Image|undefined}

Fills the entire image with a single color.

Parameters:
Name Type Description
color Array.<number>

An array of four numbers representing the R, G, B, and A channels as float values. 0-1 is the SDR range, values >1 push into the HDR headroom (requires an HDR canvas with extended tone mapping to become visible).

View Source src/Float16Image.ts, line 316

The Float16Image instance for method chaining, or undefined if the color array is invalid.

Float16Image | undefined

# getImageData() → {ImageData|null}

Creates a standard ImageData object from the Float16Image data.

View Source src/Float16Image.ts, line 364

An ImageData object, or null if the data is undefined.

ImageData | null

# pixelCallback(fn)

Iterates through each pixel of the image and applies a callback function to its data.

Parameters:
Name Type Description
fn HDRPixelCallback

The callback function to apply to each pixel.

View Source src/Float16Image.ts, line 380

# scaled(gain, optionsopt) → {Float16Image}

Returns a copy of the image with applyGain() applied, leaving the original untouched.

Parameters:
Name Type Attributes Description
gain number | Array.<number>

Uniform gain or per-channel [r, g, b] gain.

options object <optional>

Options, see applyGain().

View Source src/Float16Image.ts, line 357

A new Float16Image with scaled RGB values.

Float16Image

# setImageData(imageData) → {void}

Sets the image data of the current Float16Image instance.

Parameters:
Name Type Description
imageData HDRImageData

The image data to set.

View Source src/Float16Image.ts, line 418

If the color space of the HDRImageData is not supported.

Error
void

# static convertArrayToRec2100_hlg(data) → {Float16Array}

Converts a Uint8ClampedArray of sRGB pixel data to a Float16Array of pixels in the rec2100-hlg color space.

Parameters:
Name Type Description
data Uint8ClampedArray

The array of 8-bit pixel data.

View Source src/Float16Image.ts, line 373

The converted 16-bit pixel data.

Float16Array

# static fromImageData(imageData) → {Float16Image}

Creates a Float16Image instance from an HDRImageData object.

Parameters:
Name Type Description
imageData HDRImageData

The image data to use.

View Source src/Float16Image.ts, line 389

If the color space of the HDRImageData is not supported.

Error

The new Float16Image instance.

Float16Image

# static fromImageDataArray(width, height, imageData) → {Float16Image}

Creates a Float16Image instance from an Uint8ClampedArray object.

Parameters:
Name Type Description
width number

The width of the image.

height number

The height of the image.

imageData HDRImageData

The image data to use.

View Source src/Float16Image.ts, line 400

If the color space of the HDRImageData is not supported.

Error

The new Float16Image instance.

Float16Image

# async static fromURL(url) → {Promise.<(Float16Image|undefined)>}

Loads an image from a URL and creates a Float16Image instance from it.

Parameters:
Name Type Description
url URL

The URL of the image to load.

View Source src/Float16Image.ts, line 409

A promise that resolves with a Float16Image instance, or undefined if the image could not be loaded.

Promise.<(Float16Image|undefined)>

# static scaleUint8ToFloat16(val) → {number}

Scales an 8-bit value to a 16-bit value. This is typically used for the alpha channel.

Parameters:
Name Type Description
val number

The 8-bit value to scale (0-255).

View Source src/Float16Image.ts, line 324

The corresponding 16-bit value.

number