I am trying to write 16-bit grayscale images to png using BufferedImage.TYPE_USHORT_GRAY. I usually write like this:
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
then
image.setRGB(x,y,Color.getRGB);
to set the pixels, and finally:
ImageIO.write(image, "png", new File(path + ".png"));
for writing to a png image.
But now I have it as an image:
BufferedImage imageGray = new BufferedImage(width, height, BufferedImage.TYPE_USHORT_GRAY);
How do I save pixels in this format? Using setRGB () with a 16-bit integer does not work, when I open the saved png file, I see that many stripes are happening.
I tried to keep a simple gradient from 0 to 65535, and then using setRGB () on the image in grayscale and checked the results in Photoshop. I see that the image consists of smaller gradients every 256 lines. I assume that setRGB () or imageIO does not work as I would like.
? ImageIO BufferedImage.TYPE_USHORT_GRAY? 8- ? 16- , , , setRGB() ( x, y)?