当前位置: 编程技术>java/j2ee
java将图片分割为几个部分示例
来源: 互联网 发布时间:2014-11-05
本文导语: 以下代码使用java将图片分割为几个部分,大家参考使用吧 代码如下:public class SegmentationImage{ public static Icon Segmentation(String imagename,int Width,int Height,int height,int width) throws Exception{ // 准备分割图片 BufferedImage img1=ImageIO.re...
以下代码使用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;
}
}
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。