The most convenient method to read an image from a source (File
s, InputStream
s, URL
s) is:
BufferedImage myImage = ImageIO.read( source );
But then, how to convert myImage
to a BufferedImage.TYPE_USHORT_565_RGB
format?
The most convenient method to read an image from a source (File
s, InputStream
s, URL
s) is:
BufferedImage myImage = ImageIO.read( source );
But then, how to convert myImage
to a BufferedImage.TYPE_USHORT_565_RGB
format?
You can create a new BufferedImage of the required type and then draw the original image on it, something like:
BufferedImage bufImg = ImageIO.read( imageURL );
BufferedImage convertedImg = new BufferedImage(bufImg.getWidth(), bufImg.getHeight(), BufferedImage.TYPE_USHORT_565_RGB);
convertedImg.getGraphics().drawImage(bufImg, 0, 0, null);
dispose()
after using drawImage(). –
Henriettahenriette © 2022 - 2024 — McMap. All rights reserved.
@user172825
Welcome to StackOverflow! I recommend you to change your username. – Residual