Java 分割图片的办法

来源:互联网 发布:163邮箱客户端软件 编辑:程序博客网 时间:2024/05/09 19:56

  Java 分割图片,将图片分割为几个部分。

  public class SegmentationImage{

  public static Icon Segmentation(String imagename,int Width,int Height,int height,int width) throws Exception{

  // 准备分割图片

  BufferedImage img1=ImageIO.read(new File(imagename));

  int half_w=img1.getWidth();

  int rgb[]=new int[half_w*img1.getHeight()];

  img1.getRGB(0, 0, half_w, img1.getHeight(), rgb, 0, half_w);

  BufferedImage img_half=new BufferedImage(half_w, img1.getHeight(), BufferedImage.TYPE_INT_ARGB);

  img_half.setRGB(Width,Height,height,img1.getHeight(), rgb,width,half_w);

  Icon returnIcon = new ImageIcon(img_half);

  return returnIcon;

  }

  }

0 0
原创粉丝点击