How can cut the image and save it block to another image?
+3
A:
If src
is a BufferedImage
, then you can cut the rectangle (x1,y1)-(x2,y2)
from it and write that to dst.png
like this:
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"));
uckelman
2010-10-14 18:43:52