public BufferedImage toBufferedImage() { final int W = rawImage.width; final int H = rawImage.height; BufferedImage image = new BufferedImage(W, H, BufferedImage.TYPE_INT_RGB); int bytesPerPixels = rawImage.bpp >> 3; //bpp = bits / pixels --> bytes / pixels for (int y = 0, pxIdx = 0; y < H; y++) { for (int x = 0; x < W; x++, pxIdx += bytesPerPixels) { image.setRGB(x, y, rawImage.getARGB(pxIdx)); } } return image; }
private static BufferedImage bufferedImageFrom(RawImage rawImage) { BufferedImage image = new BufferedImage(rawImage.width, rawImage.height, TYPE_INT_ARGB); int index = 0; int bytesPerPixel = rawImage.bpp >> 3; for (int y = 0; y < rawImage.height; y++) { for (int x = 0; x < rawImage.width; x++) { image.setRGB(x, y, rawImage.getARGB(index) | 0xff000000); index += bytesPerPixel; } } return image; }
private static BufferedImage bufferedImageFrom(RawImage rawImage) { BufferedImage image = new BufferedImage(rawImage.width, rawImage.height, TYPE_INT_ARGB); int index = 0; int bytesPerPixel = rawImage.bpp >> 3; for (int y = 0; y < rawImage.height; y++) { for (int x = 0; x < rawImage.width; x++) { image.setRGB(x, y, rawImage.getARGB(index) | 0xff000000); index += bytesPerPixel; } } return image; }
private BufferedImage bufferedImageFrom(RawImage rawImage) { BufferedImage image = new BufferedImage(rawImage.width, rawImage.height, TYPE_INT_ARGB); int index = 0; int bytesPerPixel = rawImage.bpp >> 3; for (int y = 0; y < rawImage.height; y++) { for (int x = 0; x < rawImage.width; x++) { image.setRGB(x, y, rawImage.getARGB(index) | 0xff000000); index += bytesPerPixel; } } return image; }
for (int y = 0; y < rawImage.height; y++) { for (int x = 0; x < rawImage.width; x++, index += indexInc) { int value = rawImage.getARGB(index); bufferedImage.setRGB(x, y, value);