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
65 lines
1.8 KiB
JavaScript
65 lines
1.8 KiB
JavaScript
/*
|
|
* Changes the Canvas Size
|
|
*/
|
|
module.exports = function canvasResize(options, UI) {
|
|
|
|
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
|
var output;
|
|
|
|
|
|
|
|
function draw(input, callback, progressObj) {
|
|
|
|
options.width = parseInt(options.width || defaults.width);
|
|
options.height = parseInt(options.height || defaults.height);
|
|
options.x = parseInt(options.x || defaults.x);
|
|
options.y = parseInt(options.y || defaults.y);
|
|
|
|
progressObj.stop(true);
|
|
progressObj.overrideFlag = true;
|
|
|
|
var step = this;
|
|
|
|
function extraManipulation(pixels) {
|
|
let newPixels = require('ndarray')(new Uint8Array(4 * options.width * options.height).fill(0), [options.width, options.height, 4]);
|
|
let iMax = options.width - options.x,
|
|
jMax = options.height - options.y;
|
|
for (let i = 0; i < iMax && i < pixels.shape[0]; i++) {
|
|
for (let j = 0; j < jMax && j < pixels.shape[1]; j++) {
|
|
let x = i + options.x, y = j + options.y;
|
|
newPixels.set(x, y, 0, pixels.get(i, j, 0));
|
|
newPixels.set(x, y, 1, pixels.get(i, j, 1));
|
|
newPixels.set(x, y, 2, pixels.get(i, j, 2));
|
|
newPixels.set(x, y, 3, pixels.get(i, j, 3));
|
|
}
|
|
}
|
|
return newPixels;
|
|
}
|
|
|
|
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,
|
|
extraManipulation: extraManipulation,
|
|
format: input.format,
|
|
image: options.image,
|
|
inBrowser: options.inBrowser,
|
|
callback: callback,
|
|
useWasm:options.useWasm
|
|
});
|
|
|
|
}
|
|
return {
|
|
options: options,
|
|
draw: draw,
|
|
output: output,
|
|
UI: UI
|
|
};
|
|
};
|