Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PackedBuffer

Hierarchy

  • PackedBuffer

Implements

Index

Constructors

constructor

Properties

Readonly format

format: PackedFormat

Readonly height

height: number

Readonly pixels

pixels: UIntArray

Readonly width

width: number

Accessors

stride

  • get stride(): number

Methods

as

blend

blit

blitCanvas

  • blitCanvas(canvas: HTMLCanvasElement | CanvasRenderingContext2D, x?: number, y?: number): void
  • Converts and blits pixels into given canvas (or canvas context) at position x, y (0,0 by default). If canvas is smaller than source buffer, only the top-left region will be written.

    Parameters

    • canvas: HTMLCanvasElement | CanvasRenderingContext2D
    • x: number = 0
    • y: number = 0

    Returns void

copy

dither

  • Applies in-place, ordered dithering using provided dither matrix (or matrix size) and desired number of dither levels, optionally specified individually (per channel). Each channel is be processed independently. Channels can be excluded from dithering by setting their target colors to zero or negative numbers.

    remarks

    A size of 1 will result in simple posterization of each channel. The numColors value(s) MUST be in the [0 .. numColorsInChannel] interval.

    Also see: defBayer, ditherPixels.

    Parameters

    Returns PackedBuffer

empty

flipY

forEach

getAt

  • getAt(x: number, y: number): number
  • Returns pixel value at given position. If pos is outside the defined region, returns a suitable zero value.

    Parameters

    • x: number
    • y: number

    Returns number

getChannel

getChannelAt

  • getChannelAt(x: number, y: number, id: number, normalized?: boolean): number
  • Parameters

    • x: number
    • y: number
    • id: number
    • normalized: boolean = false

    Returns number

getRegion

invert

isPremultiplied

  • isPremultiplied(): boolean

postmultiply

premultiply

resize

scale

setAt

setChannel

setChannelAt

  • setChannelAt(x: number, y: number, id: number, col: number, normalized?: boolean): PackedBuffer

toImageData

  • toImageData(): ImageData

upsize

Static fromCanvas

Static fromImage

  • Creates a new pixel buffer from given HTML image element with optional support for format conversion (default: ABGR8888 & resizing.

    Parameters

    • img: HTMLImageElement
    • Optional fmt: PackedFormat
    • Optional width: number
    • height: undefined | number = ...

    Returns PackedBuffer

Generated using TypeDoc