我试图将JPanel的快照保存为.png文件。问题是我可以创建的图像默认为96DPI。由于这些图片必须打印,我需要更高的质量水平。有什么方法可以提高我的图像质量吗?是否有更聪明的方法来拍摄JPanel的快照? 您可以在此处找到我的代码的附加部分,其中变量" c"代表JPanel。 提前谢谢。
//c stands for my JPanel
BufferedImage im = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB);
//calculate x,y,width and height basing on the particular image crop I want to get
int x = roundToInt(cropFrame.getX()*panel.getScale()+groupPathways_layout.getX()-viewArea_data.getX());
int y = roundToInt(cropFrame.getY()*panel.getScale()+groupPathways_layout.getY()-viewArea_data.getY());
int w = roundToInt(cropFrame.getWidth()*panel.getScale());
int h = roundToInt(cropFrame.getHeight()*panel.getScale());
c.paint(im.getGraphics());
BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
bi.getGraphics().drawImage(im, 0, 0, w, h, x, y, x + w, y + h, null);
ImageIO.write(bi, "png", new File(path+"/"+name+imageFormat));