Added support for Streamdeck Pedal and updated UI to better fit the Packed UI style
This commit is contained in:
42
node_modules/@elgato-stream-deck/node-lib/dist/jpeg.js
generated
vendored
Normal file
42
node_modules/@elgato-stream-deck/node-lib/dist/jpeg.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.encodeJPEG = encodeJPEG;
|
||||
const jpegJS = require("jpeg-js");
|
||||
const DEFAULT_QUALITY = 95;
|
||||
/**
|
||||
* The default JPEG encoder.
|
||||
* `@julusian/jpeg-turbo` will be used if it can be found, otherwise it will fall back to `jpeg-js`
|
||||
* @param buffer The buffer to convert
|
||||
* @param width Width of the image
|
||||
* @param height Hieght of the image
|
||||
*/
|
||||
async function encodeJPEG(buffer, width, height, options) {
|
||||
try {
|
||||
const jpegTurbo = await Promise.resolve().then(() => require('@julusian/jpeg-turbo'));
|
||||
// Try using jpeg-turbo if it is available
|
||||
if (jpegTurbo.bufferSize && !!jpegTurbo.compress) {
|
||||
const encodeOptions = {
|
||||
format: jpegTurbo.FORMAT_RGBA,
|
||||
width,
|
||||
height,
|
||||
quality: DEFAULT_QUALITY,
|
||||
...options,
|
||||
};
|
||||
if (buffer.length === width * height * 4) {
|
||||
const tmpBuffer = Buffer.alloc(jpegTurbo.bufferSize(encodeOptions));
|
||||
return jpegTurbo.compress(Buffer.from(buffer), tmpBuffer, encodeOptions); // Future: avoid rewrap
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (_e) {
|
||||
// TODO - log error
|
||||
}
|
||||
// If jpeg-turbo is unavailable or fails, then fallback to jpeg-js
|
||||
const jpegBuffer2 = jpegJS.encode({
|
||||
width,
|
||||
height,
|
||||
data: buffer,
|
||||
}, options ? options.quality : DEFAULT_QUALITY);
|
||||
return jpegBuffer2.data;
|
||||
}
|
||||
//# sourceMappingURL=jpeg.js.map
|
||||
Reference in New Issue
Block a user