xBRjs
JS implementation of the xBR image scaling algorytm by Hyllian.
Installation
# npm npm install xbr-js --save # yarn yarn add xbr-js
Usage
; ... const scaledWidth = sourceWidth * 2 scaledHeight = sourceHeight * 2 originalImageData = context; const originalPixelView = originalImageDatadatabuffer; const scaledPixelView = ; const scaledImageData = scaledPixelViewbuffer scaledWidth scaledHeight;canvaswidth = scaledWidth;canvasheight = scaledHeight; context;
API
Uint32Array
xbr2x([array], [width], [height], [options]) ⇒ Returns a typed array with the pixels that form the scaled image.
Param | Type | Description |
---|---|---|
array | Uint32Array | The input pixels in ARGB format |
width | number | The width of the original image |
height | number | The height of the original image |
[options.blendColors] | boolean | Determines if new colors will be created. Defaults to true. |
[options.scaleAlpha] | boolean | Determines whether to upscale the alpha channel using the xBR algorythm. Defaults to false. |
Demo
Check it out here.