如何剪切图像并将其块保存到另一张图像?
发布于 2010-10-15 02:43:53
如果src是一个BufferedImage,那么你可以将矩形的(x1,y1)-(x2,y2)从其中剪切出来,然后像这样写到dst.png中:
final BufferedImage dst = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g = dst.createGraphics();
g.drawImage(src, x1, y1, x2, y2, null);
g.dispose();
ImageIO.write(dst, "PNG", new FileOutputStream("dst.png"));https://stackoverflow.com/questions/3936373
复制相似问题