参见java.awt.image.BufferedImage getSubimage public BufferedImage getSubimage(int x, int y, int w, int h)返回由指定矩形区域定义的子图像。返回的 BufferedImage 与源图像共享相同的数据数组。DEMOimport java.io.File; import javax.imageio.ImageIO; import java.awt.image.BufferedImage;public class Test { File picFile = new File("path"); BufferedImage bi;
public Test() { try { bi = ImageIO.read(picFile); } catch(Exception ex) { ex.printStackTrace(); } }
public BufferedImage getChildImage(int x, int y, int w, int h) { return bi.getSubimage(x, y, w, h); } }
http://hi.csdn.net/space-3318943-do-album-picid-920675.html
getSubimage
public BufferedImage getSubimage(int x,
int y,
int w,
int h)返回由指定矩形区域定义的子图像。返回的 BufferedImage 与源图像共享相同的数据数组。DEMOimport java.io.File;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;public class Test
{
File picFile = new File("path");
BufferedImage bi;
public Test()
{
try
{
bi = ImageIO.read(picFile);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
public BufferedImage getChildImage(int x, int y, int w, int h)
{
return bi.getSubimage(x, y, w, h);
}
}