From 2be7a3dca6a5b6def66eb04db8b41bc891e95817 Mon Sep 17 00:00:00 2001 From: Slytherin <31225007+Divy123@users.noreply.github.com> Date: Thu, 18 Apr 2019 17:10:36 +0530 Subject: [PATCH] Fixes crop module bug (#1019) * Fixes crop module bug * Fixes crop functionality * Add looks like test for crop module --- examples/index.html | 3 +++ examples/lib/defaultHtmlStepUi.js | 2 +- package.json | 2 +- src/modules/Crop/Crop.js | 13 +++++++--- src/modules/Crop/Ui.js | 3 ++- src/modules/Crop/info.json | 8 +++---- test/core/modules/crop.js | 40 +++++++++++++++++++++++++++++++ 7 files changed, 61 insertions(+), 10 deletions(-) create mode 100644 test/core/modules/crop.js diff --git a/examples/index.html b/examples/index.html index 076ef8bad2..fb461052ef 100644 --- a/examples/index.html +++ b/examples/index.html @@ -36,10 +36,13 @@ + + + diff --git a/examples/lib/defaultHtmlStepUi.js b/examples/lib/defaultHtmlStepUi.js index cc8b032172..679b545ef7 100644 --- a/examples/lib/defaultHtmlStepUi.js +++ b/examples/lib/defaultHtmlStepUi.js @@ -206,7 +206,7 @@ function DefaultHtmlStepUi(_sequencer, options) { $(input) .data('initValue', $(input).val()) .data('hasChangedBefore', false) - .on('input', function() { + .on('input change' , function() { $(this) .focus() .data('hasChangedBefore', diff --git a/package.json b/package.json index 623e427634..90c0477e64 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "src/ImageSequencer.js", "scripts": { "debug": "TEST=true node ./index.js -i ./examples/images/monarch.png -s invert", - "test": "TEST=true istanbul cover tape test/core/*.js test/core/ui/user-interface.js test/core/modules/canvas-resize.js test/core/modules/QR.js | tap-spec; browserify test/core/modules/image-sequencer.js test/core/modules/chain.js test/core/modules/meta-modules.js test/core/modules/replace.js test/core/modules/import-export.js test/core/modules/run.js test/core/modules/dynamic-imports.js test/core/util/parse-input.js test/core/modules/benchmark.js| tape-run --render=\"tap-spec\"", + "test": "TEST=true istanbul cover tape test/core/*.js test/core/ui/user-interface.js test/core/modules/canvas-resize.js test/core/modules/QR.js test/core/modules/crop.js | tap-spec; browserify test/core/modules/image-sequencer.js test/core/modules/chain.js test/core/modules/meta-modules.js test/core/modules/replace.js test/core/modules/import-export.js test/core/modules/run.js test/core/modules/dynamic-imports.js test/core/util/parse-input.js test/core/modules/benchmark.js| tape-run --render=\"tap-spec\"", "test-ui": "jasmine test/spec/*.js", "setup": "npm i && npm i -g grunt grunt-cli && grunt build", "start": "grunt serve" diff --git a/src/modules/Crop/Crop.js b/src/modules/Crop/Crop.js index 52213b3061..5b0168154e 100644 --- a/src/modules/Crop/Crop.js +++ b/src/modules/Crop/Crop.js @@ -21,14 +21,21 @@ module.exports = function Crop(input,options,callback) { for(var i = 0; i < w ; i++){ backgroundArray = backgroundArray.concat([backgroundColor[0],backgroundColor[1],backgroundColor[2],backgroundColor[3]]); } - var newarray = new Uint8Array(4*w*h); + // var newarray = new Uint8Array(4*w*h); + var array = [] for (var n = oy; n < oy + h; n++) { + var offsetValue = 4*w*n; if(n