BufferedImage image = new BufferedImage(1200,60, BufferedImage.TYPE_INT_RGB); //截取大小
Graphics2D g2 = image.createGraphics();
g2.translate(-1200, -60); // 截取起点
jpanel.paint(g2); // instead of just paint(g2);
ImageIO.write(image, "jpeg",
new java.io.File("a file.jpg"));
截取JPanel的部分内容并保存为图片
最新推荐文章于 2021-02-19 13:25:04 发布