我可以写入图像,但其默认分辨率是 600x450。 我想指定我自己的分辨率。
public void save(String path, String name) throws IOException
{
int x ;
int y;
x=scaled.getHeight();
y=scaled.getWidth();
System.out.println(x);
System.out.println(y);
if (scaled != null)
{
name += scaled.getWidth() + "x" + scaled.getHeight();
ImageIO.write(scaled, "png", new File(path + File.separator + name + ".png"));
}
else
{
throw new NullPointerException("Scaled instance is null");
}
}
有什么建议吗?
最佳答案
使用AffineTransformOp
,如图 here ,或Image#getScaledInstance()
,如图 here .
关于java - 如何为新生成的图像提供分辨率?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18098930/