U
Uli Kunkel
I have to downsize an image (about 10 times) and rotate it.
I heard that Image.getScaledInstance() is not very god to use for this.
Original image scale is 320x240.
For now I'm using Graphics2D and drawImage(). This is the relevant part
of the code:
----------------
Image image = new ImageIcon(buffer).getImage();
BufferedImage bim = new BufferedImage(240, 320, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = (Graphics2D)(bim.createGraphics());
g2d.translate(0, 320); //counterclockwise
g2d.rotate(- Math.PI/2);
g2d.drawImage(image, 0, 0, 320, 240, picturelabel);
----------------
The photo is rotated ok, but the resizing part gives a very low quality
photo.I read that for multiple downsizing (> 2) it is best to do it with
multiple passes.
I tried using the code from:
http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html
but I end up with a entirely black photo.I must be doing something wrong.
Any suggestions would be appreciated.
I heard that Image.getScaledInstance() is not very god to use for this.
Original image scale is 320x240.
For now I'm using Graphics2D and drawImage(). This is the relevant part
of the code:
----------------
Image image = new ImageIcon(buffer).getImage();
BufferedImage bim = new BufferedImage(240, 320, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = (Graphics2D)(bim.createGraphics());
g2d.translate(0, 320); //counterclockwise
g2d.rotate(- Math.PI/2);
g2d.drawImage(image, 0, 0, 320, 240, picturelabel);
----------------
The photo is rotated ok, but the resizing part gives a very low quality
photo.I read that for multiple downsizing (> 2) it is best to do it with
multiple passes.
I tried using the code from:
http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html
but I end up with a entirely black photo.I must be doing something wrong.
Any suggestions would be appreciated.