颤动:从图像获取像素颜色

时间:2019-04-03 13:07:35

标签: flutter

试图获取纯黄色图像的第一个像素。但是,我为RGB获取的值是错误的。

var image = NetworkImage("https://www.lockwoodmathewsmansion.com/wp-content/uploads/2017/05/yellow-square.jpg");
image.obtainKey(ImageConfiguration()).then((val) {
    var load = image.load(val);
    load.addListener((listener, err) {
        listener.image.toByteData().then((byteData) {
            var e = byteData.getUint32(500);
            debugPrint(((e >> 16) & 0xFF).toString()); // red
            debugPrint(((e >> 8) & 0xFF).toString()); // green
            debugPrint(((e) & 0xFF).toString()); // blue
        });
    });
});

0 个答案:

没有答案