帮忙看看这是 什么程序 ~~~
public void saveJPG(Image img, String s) {
BufferedImage bi = (BufferedImage) createImage(imgWidth, imgHeight);
/*
* BufferedImage bi = new BufferedImage( img.getWidth(null),
* img.getHeight(null), BufferedImage.TYPE_INT_RGB);
*/
Graphics2D g2 = bi.createGraphics();
g2.clipRect(rectX, rectY, rectWidth, rectHeight);
g2.drawImage(img, null, null);
int moveX = rectX > 0 ? rectX : 0;
int moveY = rectY > 0 ? rectY : 0;
int cutWidth = rectX + rectWidth > imgWidth ? rectWidth
- ((rectX + rectWidth) - imgWidth) : rectWidth;
int cutHeight = rectY + rectHeight > imgHeight ? rectHeight
- ((rectY + rectHeight) - imgHeight) : rectHeight;
bi = bi.getSubimage(moveX, moveY, cutWidth, cutHeight);
FileOutputStream out = null;
try {
out = new FileOutputStream(s);
} catch (java.io.FileNotFoundException io) {
System.out.println("File Not Found");
}
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
param.setQuality(1f, false);
encoder.setJPEGEncodeParam(param);
try {
encoder.encode(bi);
out.close();
} catch (java.io.IOException io) {
System.out.println("IOException");
}
}