Add premultiplied boolean flag for raw pixel data input (#2685)

This commit is contained in:
Michael Nutt
2021-05-03 14:30:37 -04:00
committed by GitHub
parent 309918a878
commit 9a1e8ed574
9 changed files with 60 additions and 1 deletions

View File

@@ -139,6 +139,8 @@ const debuglog = util.debuglog('sharp');
* @param {number} [options.raw.width] - integral number of pixels wide.
* @param {number} [options.raw.height] - integral number of pixels high.
* @param {number} [options.raw.channels] - integral number of channels, between 1 and 4.
* @param {boolean} [options.raw.premultiplied] - specifies that the raw input has already been premultiplied, set to `true`
* to avoid sharp premultiplying the image. (optional, default `false`)
* @param {Object} [options.create] - describes a new image to be created.
* @param {number} [options.create.width] - integral number of pixels wide.
* @param {number} [options.create.height] - integral number of pixels high.

View File

@@ -103,6 +103,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
inputDescriptor.rawWidth = inputOptions.raw.width;
inputDescriptor.rawHeight = inputOptions.raw.height;
inputDescriptor.rawChannels = inputOptions.raw.channels;
inputDescriptor.rawPremultiplied = !!inputOptions.raw.premultiplied;
} else {
throw new Error('Expected width, height and channels for raw pixel input');
}