解决方法
你必须编写自己的算法.我想你可以移动
this one飞镖.
Color getPixelColor(ByteData rgbaImageData,int imageWidth,int imageHeight,int x,int y) { assert(x >= 0 && x < imageWidth); assert(y >= 0 && y < imageHeight); final byteOffset = x * 4 + y * imageWidth * 4; final r = rgbaImageData.getUint8(byteOffset); final g = rgbaImageData.getUint8(byteOffset + 1); final b = rgbaImageData.getUint8(byteOffset + 2); final a = rgbaImageData.getUint8(byteOffset + 3); return Color.fromARGB(a,r,g,b); }
你可以像这样使用它:
Image image = ...; final rgbaImageData = await image.toByteData(format: ui.ImageByteFormat.rawRgba); print(getPixelColor(rgbaImageData,image.width,image.height,x,y));
操作它遵循相同的方案(setUint8).