// from: https://stackoverflow.com/questions/14416107/int-array-to-bufferedimage // pixels are RGB pixels static BufferedImageWithMeta intArrayToBufferedImage(int[] pixels, int w, int h default pixels.length/w) { if (w == 0 || h == 0) null; int[] bitMasks = new int[]{0xFF0000, 0xFF00, 0xFF, 0xFF000000}; SinglePixelPackedSampleModel sm = new(DataBuffer.TYPE_INT, w, h, bitMasks); DataBufferInt db = new DataBufferInt(pixels, pixels.length); WritableRaster wr = Raster.createWritableRaster(sm, db, new Point); ret new BufferedImageWithMeta(ColorModel.getRGBdefault(), wr, false, null); } static BufferedImageWithMeta intArrayToBufferedImage(int w, int... pixels) { ret intArrayToBufferedImage(pixels, w); }