folkyatina is suitable if your RGB values ββare in the order of B, G, R, but if they are in the order of R, G, B, I found the following code to work:
DataBuffer rgbData = new DataBufferByte(rgbs, rgbs.length); WritableRaster raster = Raster.createInterleavedRaster( rgbData, width, height, width * 3, // scanlineStride 3, // pixelStride new int[]{0, 1, 2}, // bandOffsets null); ColorModel colorModel = new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_sRGB), new int[]{8, 8, 8}, // bits false, // hasAlpha false, // isPreMultiplied ComponentColorModel.OPAQUE, DataBuffer.TYPE_BYTE); return new BufferedImage(colorModel, raster, false, null);
Mutant bob
source share