If you have an java.awt.Image
, rezising it doesn't require any additional libraries.
(如果您具有java.awt.Image
,则对其进行大小调整不需要任何其他库。)
Just do: (做就是了:)
Image newImage = yourImage.getScaledInstance(newWidth, newHeight, Image.SCALE_DEFAULT);
Ovbiously, replace newWidth
and newHeight
with the dimensions of the specified image.
(Ovbiously, 取代 newWidth
和newHeight
具有指定图像的尺寸。)
Notice the last parameter: it tells to the runtime the algorithm you want to use for resizing.
(注意最后一个参数:它向运行时告知您要用于调整大小的算法 。)
There are algorithms that produce a very precise result, however these take a large time to complete.
(有些算法可以产生非常精确的结果,但是这些算法需要花费大量时间才能完成。)
You can use any of the following algorithms:
(您可以使用以下任何算法:)
See the Javadoc for more info.
(有关更多信息,请参见Javadoc 。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…