I am looking for the simplest (and still not problematic) way to resize BufferedImage in Java.
In some answer to the question, the coobird user suggested the following solution, according to him (very little changed by me):
**
The object Graphicshas a drawing method Image, and also performs a resize operation:
Graphics.drawImage(Image, int, int, int, int, ImageObserver)
The method can be used to indicate the location along with the size of the image when drawing.
So, we could use a piece of code as follows:
BufferedImage originalImage =
BufferedImage newImage = new BufferedImage(SMALL_SIZE, SMALL_SIZE, BufferedImage.TYPE_INT_RGB);
Graphics g = newImage.createGraphics();
g.drawImage(originalImage, 0, 0, SMALL_SIZE, SMALL_SIZE, null);
g.dispose();
It will take originalImageand draw it on newImagewith width and height SMALL_SIZE.
**
This solution seems pretty simple. I have two questions:
, .