说明图片是切好,但切出的图片显示全黑色。请高手帮忙!
/** 
* 图片切割 
* @param srcImageFile 图片地址 
* @param ImageFile 图片存放的地址 
* @param w 切割宽度 
* @param h 切割高度 
* @param x1 开始x结点(left) 
* @param y1 开始y结点(top) 
* @param sw 图片宽度 
* @param sh 图片高度 
 * @throws IOException 
*/ 
public static void cut(String srcImageFile,String ImageFile, int w, int h, int x1, int y1, int sw, int sh) throws IOException { 
// http://localhost:8080/ImpCra/createServlet?p=Sunset.jpg&x=117&y=201&w=61&h=50&pw=300&ph=400 
Image img; 
ImageFilter cropFilter; 

// 读取源图像 
BufferedImage bi = ImageIO.read(new File(srcImageFile)); 

if (sw >= w && sh >= h) { 
//创建此图像的缩放版本
//Image image = bi.getScaledInstance(sw, sh, Image.SCALE_DEFAULT); 


// 四个参数分别为图像起点坐标和宽高 
// 即: CropImageFilter(int x,int y,int width,int height) 
// 按指定 x、y、w 和 h 参数从源 Image 提取绝对矩形区域来构造 CropImageFilter
cropFilter = new CropImageFilter(x1, y1, w, h); 

img = Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(bi.getSource(), cropFilter)); 
BufferedImage tag = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); 
Graphics g = tag.getGraphics(); 
g.drawImage(img, 0, 0, null); // 绘制缩小后的图 
 g.dispose(); 
// 输出为文件 
ImageIO.write(tag, "JPEG", new File(ImageFile));