Commit 8c9e8d09 authored by Winsley's avatar Winsley

Added input field to specifiy blockBits

parent 5e374c98
Pipeline #41543537 passed with stages
in 58 seconds
......@@ -38,6 +38,8 @@
<input type='file' id='image' />
<label for='selection'>Selection</label>
<input type='text' id='selection' />
<label for='blockBits'>Block Bits</label>
<input type='text' id='blockBits' value='8' />
<label for='result'>Result</label>
<input type='text' id='result' />
</form>
......
......@@ -2,12 +2,14 @@
function handleForm(form) {
let image = form.querySelector('#image');
let handler = (ev) => {
console.log('handler');
let reader = new FileReader();
reader.onload = (ev) => {
let imageElement = new Image();
imageElement.onload = () => {
let canvas = document.querySelector('#canvas');
let blockBits = parseInt(
document.querySelector('#blockBits').value, 10);
let selection =
(document.querySelector('#selection').value || '').split('x');
......@@ -16,8 +18,6 @@ function handleForm(form) {
let sWidth = selection[2] || imageElement.width;
let sHeight = selection[3] || imageElement.height;
console.log(selection, sX, sY, sWidth, sHeight);
canvas.width = sWidth;
canvas.height = sHeight;
......@@ -28,7 +28,7 @@ function handleForm(form) {
let imageData = context.getImageData(0, 0, sWidth, sHeight);
let result = form.querySelector('#result');
result.value = blockhashjs.blockhashData(imageData, 8, 2);
result.value = blockhashjs.blockhashData(imageData, blockBits, 2);
};
imageElement.src = ev.target.result;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment