Class

Float16Image

Float16Image(width, height, colorspaceopt)

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)

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 DEFAULT_COLORSPACE.

View Source src/Float16Image.ts, line 12

Classes

Float16Image
Float16Image
Float16Image
Float16Image

Members

# COLORSPACES

A mapping of predefined HDR color space names to their corresponding colorjs.io string representations.

View Source src/Float16Image.ts, line 26

# COLORSPACES

A mapping of predefined HDR color space names to their corresponding colorjs.io string representations.

View Source src/Float16Image.ts, line 26

# DEFAULT_COLORSPACE

The default color space for new images, set to "rec2100-hlg".

View Source src/Float16Image.ts, line 20

# DEFAULT_COLORSPACE

The default color space for new images, set to "rec2100-hlg".

View Source src/Float16Image.ts, line 20

# DEFAULT_PIXELFORMAT

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

View Source src/Float16Image.ts, line 22

# DEFAULT_PIXELFORMAT

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

View Source src/Float16Image.ts, line 22

# SDR_MULTIPLIER

A multiplier used for scaling 8-bit SDR values to 16-bit.

View Source src/Float16Image.ts, line 24

# SDR_MULTIPLIER

A multiplier used for scaling 8-bit SDR values to 16-bit.

View Source src/Float16Image.ts, line 24

# colorSpace

The color space of the image.

View Source src/Float16Image.ts, line 33

HDRPredefinedColorSpace

# colorSpace

The color space of the image.

View Source src/Float16Image.ts, line 311

# colorSpace

The color space of the image.

View Source src/Float16Image.ts, line 33

HDRPredefinedColorSpace

# colorSpace

The color space of the image.

View Source src/Float16Image.ts, line 311

# data

The raw pixel data stored as a Float16Array.

View Source src/Float16Image.ts, line 18

Float16Array

# data

The raw pixel data stored as a Float16Array.

View Source src/Float16Image.ts, line 293

# data

The raw pixel data stored as a Float16Array.

View Source src/Float16Image.ts, line 18

Float16Array

# data

The raw pixel data stored as a Float16Array.

View Source src/Float16Image.ts, line 293

# height

The height of the image in pixels.

View Source src/Float16Image.ts, line 14

number

# height

The height of the image in pixels.

View Source src/Float16Image.ts, line 285

# height

The height of the image in pixels.

View Source src/Float16Image.ts, line 14

number

# height

The height of the image in pixels.

View Source src/Float16Image.ts, line 285

# width

The width of the image in pixels.

View Source src/Float16Image.ts, line 16

number

# width

The width of the image in pixels.

View Source src/Float16Image.ts, line 289

# width

The width of the image in pixels.

View Source src/Float16Image.ts, line 16

number

# width

The width of the image in pixels.

View Source src/Float16Image.ts, line 289

Record.<HDRPredefinedColorSpace, ColorTypes>

# static COLORSPACES

A mapping of predefined HDR color space names to their corresponding colorjs.io string representations.

View Source src/Float16Image.ts, line 307

Record.<HDRPredefinedColorSpace, ColorTypes>

# static COLORSPACES

A mapping of predefined HDR color space names to their corresponding colorjs.io string representations.

View Source src/Float16Image.ts, line 307

HDRPredefinedColorSpace

# static DEFAULT_COLORSPACE

The default color space for new images, set to "rec2100-hlg".

View Source src/Float16Image.ts, line 297

HDRPredefinedColorSpace

# static DEFAULT_COLORSPACE

The default color space for new images, set to "rec2100-hlg".

View Source src/Float16Image.ts, line 297

"rgba-float16"

# static DEFAULT_PIXELFORMAT

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

View Source src/Float16Image.ts, line 301

"rgba-float16"

# static DEFAULT_PIXELFORMAT

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

View Source src/Float16Image.ts, line 301

# static SDR_MULTIPLIER

A multiplier used for scaling 8-bit SDR values to 16-bit.

View Source src/Float16Image.ts, line 303

# static SDR_MULTIPLIER

A multiplier used for scaling 8-bit SDR values to 16-bit.

View Source src/Float16Image.ts, line 303

Methods

# 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 (0-65535).

View Source src/Float16Image.ts, line 329

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 363

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

ImageData | null

# getPixel(w, h) → {Float16Array}

Retrieves the pixel data at a specified coordinate.

Parameters:
Name Type Description
w number

The x-coordinate (width).

h number

The y-coordinate (height).

View Source src/Float16Image.ts, line 338

A new Float16Array containing the R, G, B, and A values of the pixel.

Float16Array

# pixelCallback(fn)

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

Parameters:
Name Type Description
fn Float16ImagePixelCallback

The callback function to apply to each pixel.

View Source src/Float16Image.ts, line 388

# 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 424

If the color space of the HDRImageData is not supported.

Error
void

# setPixel(w, h, px) → {void}

Sets the pixel data at a specified coordinate.

Parameters:
Name Type Description
w number

The x-coordinate (width).

h number

The y-coordinate (height).

px Array.<number>

An array of four numbers representing the R, G, B, and A channels.

View Source src/Float16Image.ts, line 348

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 381

The converted 16-bit pixel data.

Float16Array

# static convertPixelToRec2100_hlg(pixel) → {Float16Array}

Converts a single 8-bit pixel (from sRGB color space) to a 16-bit pixel in the rec2100-hlg color space.

Parameters:
Name Type Description
pixel Uint8ClampedArray

An array of four 8-bit numbers (R, G, B, A).

View Source src/Float16Image.ts, line 372

The converted 16-bit pixel in the rec2100-hlg color space.

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 406

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 415

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

Promise.<(Float16Image|undefined)>

# async static loadSDRImageData(url) → {Promise.<(HDRImageData|undefined)>}

Loads an SDR image from a URL and returns its image data.

Parameters:
Name Type Description
url URL

The URL of the image to load.

View Source src/Float16Image.ts, line 397

A promise that resolves with the HDRImageData or undefined if loading fails.

Promise.<(HDRImageData|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 356

The corresponding 16-bit value.

number

Float16ImageFloat16Image(width, height, colorspaceopt)

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)

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 DEFAULT_COLORSPACE.

View Source src/Float16Image.ts, line 12

Classes

Float16Image
Float16Image
Float16Image
Float16Image

Members

# COLORSPACES

A mapping of predefined HDR color space names to their corresponding colorjs.io string representations.

View Source src/Float16Image.ts, line 26

# COLORSPACES

A mapping of predefined HDR color space names to their corresponding colorjs.io string representations.

View Source src/Float16Image.ts, line 26

# DEFAULT_COLORSPACE

The default color space for new images, set to "rec2100-hlg".

View Source src/Float16Image.ts, line 20

# DEFAULT_COLORSPACE

The default color space for new images, set to "rec2100-hlg".

View Source src/Float16Image.ts, line 20

# DEFAULT_PIXELFORMAT

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

View Source src/Float16Image.ts, line 22

# DEFAULT_PIXELFORMAT

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

View Source src/Float16Image.ts, line 22

# SDR_MULTIPLIER

A multiplier used for scaling 8-bit SDR values to 16-bit.

View Source src/Float16Image.ts, line 24

# SDR_MULTIPLIER

A multiplier used for scaling 8-bit SDR values to 16-bit.

View Source src/Float16Image.ts, line 24

# colorSpace

The color space of the image.

View Source src/Float16Image.ts, line 33

HDRPredefinedColorSpace

# colorSpace

The color space of the image.

View Source src/Float16Image.ts, line 311

# colorSpace

The color space of the image.

View Source src/Float16Image.ts, line 33

HDRPredefinedColorSpace

# colorSpace

The color space of the image.

View Source src/Float16Image.ts, line 311

# data

The raw pixel data stored as a Float16Array.

View Source src/Float16Image.ts, line 18

Float16Array

# data

The raw pixel data stored as a Float16Array.

View Source src/Float16Image.ts, line 293

# data

The raw pixel data stored as a Float16Array.

View Source src/Float16Image.ts, line 18

Float16Array

# data

The raw pixel data stored as a Float16Array.

View Source src/Float16Image.ts, line 293

# height

The height of the image in pixels.

View Source src/Float16Image.ts, line 14

number

# height

The height of the image in pixels.

View Source src/Float16Image.ts, line 285

# height

The height of the image in pixels.

View Source src/Float16Image.ts, line 14

number

# height

The height of the image in pixels.

View Source src/Float16Image.ts, line 285

# width

The width of the image in pixels.

View Source src/Float16Image.ts, line 16

number

# width

The width of the image in pixels.

View Source src/Float16Image.ts, line 289

# width

The width of the image in pixels.

View Source src/Float16Image.ts, line 16

number

# width

The width of the image in pixels.

View Source src/Float16Image.ts, line 289

Record.<HDRPredefinedColorSpace, ColorTypes>

# static COLORSPACES

A mapping of predefined HDR color space names to their corresponding colorjs.io string representations.

View Source src/Float16Image.ts, line 307

Record.<HDRPredefinedColorSpace, ColorTypes>

# static COLORSPACES

A mapping of predefined HDR color space names to their corresponding colorjs.io string representations.

View Source src/Float16Image.ts, line 307

HDRPredefinedColorSpace

# static DEFAULT_COLORSPACE

The default color space for new images, set to "rec2100-hlg".

View Source src/Float16Image.ts, line 297

HDRPredefinedColorSpace

# static DEFAULT_COLORSPACE

The default color space for new images, set to "rec2100-hlg".

View Source src/Float16Image.ts, line 297

"rgba-float16"

# static DEFAULT_PIXELFORMAT

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

View Source src/Float16Image.ts, line 301

"rgba-float16"

# static DEFAULT_PIXELFORMAT

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

View Source src/Float16Image.ts, line 301

# static SDR_MULTIPLIER

A multiplier used for scaling 8-bit SDR values to 16-bit.

View Source src/Float16Image.ts, line 303

# static SDR_MULTIPLIER

A multiplier used for scaling 8-bit SDR values to 16-bit.

View Source src/Float16Image.ts, line 303

Methods

# 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 (0-65535).

View Source src/Float16Image.ts, line 329

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 363

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

ImageData | null

# getPixel(w, h) → {Float16Array}

Retrieves the pixel data at a specified coordinate.

Parameters:
Name Type Description
w number

The x-coordinate (width).

h number

The y-coordinate (height).

View Source src/Float16Image.ts, line 338

A new Float16Array containing the R, G, B, and A values of the pixel.

Float16Array

# pixelCallback(fn)

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

Parameters:
Name Type Description
fn Float16ImagePixelCallback

The callback function to apply to each pixel.

View Source src/Float16Image.ts, line 388

# 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 424

If the color space of the HDRImageData is not supported.

Error
void

# setPixel(w, h, px) → {void}

Sets the pixel data at a specified coordinate.

Parameters:
Name Type Description
w number

The x-coordinate (width).

h number

The y-coordinate (height).

px Array.<number>

An array of four numbers representing the R, G, B, and A channels.

View Source src/Float16Image.ts, line 348

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 381

The converted 16-bit pixel data.

Float16Array

# static convertPixelToRec2100_hlg(pixel) → {Float16Array}

Converts a single 8-bit pixel (from sRGB color space) to a 16-bit pixel in the rec2100-hlg color space.

Parameters:
Name Type Description
pixel Uint8ClampedArray

An array of four 8-bit numbers (R, G, B, A).

View Source src/Float16Image.ts, line 372

The converted 16-bit pixel in the rec2100-hlg color space.

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 406

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 415

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

Promise.<(Float16Image|undefined)>

# async static loadSDRImageData(url) → {Promise.<(HDRImageData|undefined)>}

Loads an SDR image from a URL and returns its image data.

Parameters:
Name Type Description
url URL

The URL of the image to load.

View Source src/Float16Image.ts, line 397

A promise that resolves with the HDRImageData or undefined if loading fails.

Promise.<(HDRImageData|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 356

The corresponding 16-bit value.

number