@kayahr/xbrz
    Preparing search index...

    Class Scaler

    Scaler instance for a specific source image size and scale factor.

    Index

    Constructors

    • Creates a new scaler instance for the given source image size and scale factor.

      Parameters

      • sourceWidth: number

        The source image width in pixels (0-8192). Fractional parts are discarded.

      • sourceHeight: number

        The source image height in pixels (0-8192). Fractional parts are discarded.

      • factor: number

        The scale factor. Must be 2, 3, 4, 5 or 6.

      • options: ScalerOptions = {}

        Optional scaler configuration. largeLut defaults to false.

      Returns Scaler

      RangeError if width, height, scale factor or largeLut is invalid.

    Accessors

    • get factor(): number

      Returns number

      The scale factor (2, 3, 4, 5 or 6).

    • get sourceHeight(): number

      Returns number

      The source image height in pixels.

    • get sourceWidth(): number

      Returns number

      The source image width in pixels.

    • get targetHeight(): number

      Returns number

      The target image height in pixels.

    • get targetWidth(): number

      Returns number

      The target image width in pixels.

    Methods

    • Scales the given source image data and returns the target image data.

      Parameters

      • source: Uint8ClampedArray

        The source image data. Size (width * height * 4) must match the image size for which the scaler was initialized.

      Returns Uint8ClampedArray<ArrayBuffer>

      The target image data. The scaler always updates and returns the same array buffer, so when you do not immediately write the buffer to a file or canvas before scaling a different image with the same scaler you might want to copy the buffer.