Reputation: 1518
I need to read image in java. Then I should to convert it to 565RGB In addition it would be good to resize this image to 320 x 240. How should I do it? Help me please.
I know such information: 1)It is possible to read image by its URL.
ImageIcon imgThisImg = new ImageIcon(imageURL);
2) It is possible to create image instances that supports 565RGB.
BufferedImage bufImg = new BufferedImage(320, 240, BufferedImage.TYPE_USHORT_565_RGB);
3)BufferedImage inherits ImageIcon , so it is possible to perform such operation
Image imgPicture ...
BufferedImage bufImg = (BufferedImage) imgPicture;
But I haven't any idea, will bufImg
in this case have BufferedImage.TYPE_USHORT_565_RGB format
?
How to stretch, to squeeze or to cut this picture to get size 320 x 240?
Upvotes: 0
Views: 693
Reputation: 1297
The most convenient method to read image from any source (File,Stream,URL) is
BufferedImage bufImg = ImageIO.read( imageURL );
Then to answer your question you should check this post How to scale a BufferedImage.
Upvotes: 1