2018-02-12 14:25:58 +00:00
|
|
|
import 'dart:html';
|
2018-02-12 14:55:45 +00:00
|
|
|
import 'package:dart_floyd_steinberg_dithering/Dither.dart';
|
2018-02-12 14:25:58 +00:00
|
|
|
|
|
|
|
CanvasElement input;
|
|
|
|
CanvasElement output;
|
|
|
|
|
|
|
|
ImageElement inputImg;
|
2018-02-12 14:55:45 +00:00
|
|
|
ImageElement outputImg;
|
2018-02-12 14:25:58 +00:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
inputImg = new ImageElement(src: 'kitten.jpg', width: 712, height: 470);
|
|
|
|
|
|
|
|
input = document.querySelector('#input');
|
|
|
|
output = document.querySelector('#output');
|
|
|
|
|
2018-02-12 14:55:45 +00:00
|
|
|
inputImg.onLoad.listen(imgLoaded);
|
2018-02-12 14:25:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void imgLoaded(Event e) {
|
|
|
|
print("image loaded");
|
|
|
|
input.context2D.drawImage(inputImg, 0, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-02-12 14:55:45 +00:00
|
|
|
ImageData getImageData(CanvasElement canvas) {
|
|
|
|
return canvas.context2D.getImageData(0, 0, canvas.width, canvas.height);
|
2018-02-12 14:25:58 +00:00
|
|
|
}
|