/** * Change color space from RGBA to RGB * @param {Object} backgroundColor in {r: 0, g: 0, b: 0} format where each component is normalized between 0 and 1 */ function RgbaToRgb(backgroundColor) { PixelStream.call(this); this.backgroundColor = { r: backgroundColor ? backgroundColor.r | 0 : 0, g: backgroundColor ? backgroundColor.g | 0 : 0, b: backgroundColor ? backgroundColor.b | 0 : 0 }; this.buffer = new BufferList(); }
function ImageEncoder(type, opts) { PixelStream.call(this, opts); var encoder = ImageEncoder.find(type, opts); if (!encoder) throw new Error('Unsupported image encoder: ' + type); this._input = encoder; this._output = encoder; }
// A test encoder // It accepts a parameter to decide what the supported color // spaces should be and outputs the pixel data unchanged. function TestEncoder(cs) { PixelStream.call(this); this.supportedColorSpaces = arguments.length ? cs : ['rgb', 'gray']; }
/** * Change color space from RGBA to RGB * @param {Object} backgroundColor in {r: 0, g: 0, b: 0} format where each component is normalized between 0 and 1 */ function ExtractAlpha() { PixelStream.call(this); this.buffer = new BufferList(); }