j2se 怎么把图片切割成相同宽高几个小图片? rt,怎么j2me上这么多实现的方法,J2se API查半天没结果,那个要怎么弄????谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 楼主是想切了之后保存为新的图片还是想切了之后用来显示在界面上?如果是在界面上那我给你个切的方法 //从指定URL直接读取图片,并剪切出{x,y,width,feight}其中的部分 public static BufferedImage cut(URL sourceURL, int x, int y, int width, int height) { BufferedImage bufImage = null; try { bufImage = ImageIO.read(sourceURL); } catch (IOException e1) { e1.printStackTrace(); } bufImage = bufImage.getSubimage(x, y, width, height); return bufImage; } //将指定的BufferedImage,剪切出{x,y,width,feight}其中的部分 public static BufferedImage cut(BufferedImage img, int x, int y, int width, int height) { BufferedImage bufImage = null; bufImage = img.getSubimage(x, y, width, height); return bufImage; } 用 ImageIO.write 可以把切好的图片以指定的编码格式生成图片文件。 java代码结果输出,大家来探讨一下 数组作为参数传递 下载了一个java 神经网络工具包,但不知道如何使用,高手请进 删除字串第二行呀第二行 菜鸟提问,一个String的对象怎么和空值比较啊? 谁能给我一段树型的源代码,送分 [求助]JAVA中强调的文件名与类名一样,这是什么问题 JSplitPane嵌套怎么不好使?? java接口的问题------ 急!!! 关于java applet的问题 JDK1.5的泛型与枚举 JDBC如何把查询出来的信息导入TABLE
还是想切了之后用来显示在界面上?
如果是在界面上
那我给你个切的方法 //从指定URL直接读取图片,并剪切出{x,y,width,feight}其中的部分
public static BufferedImage cut(URL sourceURL, int x, int y, int width, int height) {
BufferedImage bufImage = null;
try {
bufImage = ImageIO.read(sourceURL);
} catch (IOException e1) {
e1.printStackTrace();
}
bufImage = bufImage.getSubimage(x, y, width, height);
return bufImage;
} //将指定的BufferedImage,剪切出{x,y,width,feight}其中的部分
public static BufferedImage cut(BufferedImage img, int x, int y, int width, int height) {
BufferedImage bufImage = null;
bufImage = img.getSubimage(x, y, width, height);
return bufImage;
}