mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-05 16:00:01 +01:00
* Add wasm code * First working model * Add PixelManipulation web assembly code to browser and node * Tests corrected for modules * Corrected test script * Add wasm bechmarks * Update Readme * Applies toggling functionality and refactored PixelManipulation code * Added documentation and corrected wasm toggling * change noise reduction module to use wasm code * Corrected formatting and removed extra comments * Add default wasm option and made README changes * Fixed negative test timings * combined benchmarks file * Update benchmark.js * Removed copies of wasm file and corrected test format * Update package.json Co-Authored-By: Jeffrey Warren <jeff@unterbahn.com> * Added wasm file and removed redundant code * Removed earlier benchmarks * move test/core/sequencer/benchmark.js to its own test command, not passing to tape-spec * Solves memory leaks and blank lines * Solves memory leaks and blank lines * Added handler for node code * Modify test script * Modify test script * Correct doc and removed pace fuctionality
60 lines
1.4 KiB
JavaScript
60 lines
1.4 KiB
JavaScript
/*
|
|
* Changes the Image Brightness
|
|
*/
|
|
module.exports = function Brightness(options, UI) {
|
|
|
|
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
|
var output;
|
|
|
|
|
|
|
|
function draw(input, callback, progressObj) {
|
|
|
|
options.brightness = options.brightness || defaults.brightness;
|
|
|
|
progressObj.stop(true);
|
|
progressObj.overrideFlag = true;
|
|
|
|
/*
|
|
In this case progress is handled by changepixel internally otherwise progressObj
|
|
needs to be overriden and used
|
|
For eg. progressObj = new SomeProgressModule()
|
|
*/
|
|
|
|
var step = this, val = (options.brightness) / 100.0;
|
|
|
|
function changePixel(r, g, b, a) {
|
|
|
|
r = Math.min(val * r, 255);
|
|
g = Math.min(val * g, 255);
|
|
b = Math.min(val * b, 255);
|
|
return [r, g, b, a];
|
|
}
|
|
|
|
function output(image, datauri, mimetype) {
|
|
|
|
// This output is accessible by Image Sequencer
|
|
step.output = { src: datauri, format: mimetype };
|
|
|
|
}
|
|
|
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
|
output: output,
|
|
ui: options.step.ui, //don't pass this in if you don't want your module to support progress bars
|
|
changePixel: changePixel,
|
|
format: input.format,
|
|
image: options.image,
|
|
inBrowser: options.inBrowser,
|
|
callback: callback,
|
|
useWasm:options.useWasm
|
|
});
|
|
|
|
}
|
|
return {
|
|
options: options,
|
|
draw: draw,
|
|
output: output,
|
|
UI: UI
|
|
};
|
|
};
|