[英]Converting a BufferedImage to another type
The most convenient method to read an image from a source ( File
s, InputStream
s, URL
s) is: 从源( File
, InputStream
, URL
)读取图像的最便捷方法是:
BufferedImage myImage = ImageIO.read( source );
But then, how to convert myImage
to a BufferedImage.TYPE_USHORT_565_RGB
format? 但是,然后如何将myImage
转换为BufferedImage.TYPE_USHORT_565_RGB
格式?
You can create a new BufferedImage of the required type and then draw the original image on it, something like: 您可以创建所需类型的新BufferedImage,然后在其上绘制原始图像,如下所示:
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.