import 'dart:html';
import 'package:dart_floyd_steinberg_dithering/Dither.dart';
CanvasElement input;
CanvasElement output;
ImageElement inputImg;
ImageElement outputImg;
void main() {
inputImg = new ImageElement(src: 'kitten.jpg', width: 712, height: 470);
input = document.querySelector('#input');
output = document.querySelector('#output');
inputImg.onLoad.listen(imgLoaded);
}
void imgLoaded(Event e) {
print("image loaded");
input.context2D.drawImage(inputImg, 0, 0);
output.context2D.putImageData( Dither.editImage( getImageData(input)), 0, 0);
}
ImageData getImageData(CanvasElement canvas) {
return canvas.context2D.getImageData(0, 0, canvas.width, canvas.height);
}