话不多说上源码
public
void crop(String src
, String dst
, int x
, int y
, int w
, int h
) throws IOException
{
BufferedImage bis
= ImageIO
.read(new
File(src
));
BufferedImage bid
= new
BufferedImage(w
, h
, 1);
Graphics2D g
= bid
.createGraphics();
g
.drawImage(bis
, 0, 0, w
, h
, x
, y
, x
+ w
, y
+ h
, null
);
ImageIO
.write(bid
, "jpg", new
FileOutputStream(dst
));
g
.dispose();
}
转载请注明原文地址: https://lol.8miu.com/read-23072.html