0

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?

Lucky Man
  • 1,488
  • 3
  • 19
  • 41

1 Answers1

1

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.

Community
  • 1
  • 1
viktor
  • 1,277
  • 10
  • 16
  • Thank you for answer. But what about changing format to 565RGB? Can I gain this goal in such way BufferedImage bufImg = new BufferedImage(320, 240, BufferedImage.TYPE_USHORT_565_RGB); BufferedImage bufImg1 = ImageIO.read( imageURL ); bufImg=bufImg1; will bufImg in necessary format? how to define it? – Lucky Man Nov 18 '11 at 23:38