static Matrix imageToMatrix(BufferedImage etc img) { if (img == null) null; int _w = img.getWidth(), h = img.getHeight(); class ImageToMatrix extends AbstractMatrix { *() { super(_w, _h); } int xyToIndex(int x, int y) { ret 2+y*w+x; } public Int get(int x, int y) { assertPointInBounds(x, y, w, h); ret img.getRGB(x, y); } public void set(int x, int y, Int a) { assertPointInBounds(x, y, w, h); int old = img.getRGB(x, y); if (old != (int) val) img.setRGB(x, y, val); ret old; } }; ret new RGAWithSizeMatrix; var intList = imagePixelsToRGBAWithSize_virtualIntList(img); ret rgbaWithSizeToIntMatrix(intList); }