From 763512a3b16afcc4ee0f332015a0a050637292cf Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 14 Feb 2018 18:00:57 +0100 Subject: [PATCH] Add Dither Effect to Example Image --- web/index.html | 4 ++-- web/main.dart | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/web/index.html b/web/index.html index 1a09a60..7dde92e 100644 --- a/web/index.html +++ b/web/index.html @@ -14,8 +14,8 @@ - + - + diff --git a/web/main.dart b/web/main.dart index ef830c7..a4c027a 100644 --- a/web/main.dart +++ b/web/main.dart @@ -8,11 +8,15 @@ ImageElement inputImg; ImageElement outputImg; void main() { - inputImg = new ImageElement(src: 'kitten.jpg', width: 712, height: 470); + inputImg = new ImageElement(src: 'kitten.jpg'); input = document.querySelector('#input'); output = document.querySelector('#output'); + input.width = inputImg.width; + input.height = inputImg.height; + output.width = inputImg.width; + output.height = inputImg.height; inputImg.onLoad.listen(imgLoaded); } @@ -20,9 +24,9 @@ void imgLoaded(Event e) { print("image loaded"); input.context2D.drawImage(inputImg, 0, 0); - PixelArray px = new PixelArray.fromImageData(getImageData(input), 712); + PixelArray px = new PixelArray.fromImageData(getImageData(input), input.width); px = Pixed.greyscale(px); - + px = Pixed.dither(px); output.context2D.putImageData(px.toImageData(), 0, 0); }