public static Image[] splitImage(Image img, int rows, int cols) {
if(img == null)
return null;
Image[] result = new Image[rows * cols];
int w = img.getWidth()/cols;
int h = img.getHeight()/rows;
for(int i = 0;i<result.length;i++){
result[i] = Image.createImage(w,h);
Graphics g = result[i].getGraphics();
g.translate((-i%cols)*w,(-i/cols)*h);
g.drawImage(img,0,0,Graphics.LEFT|Graphics.TOP);
}
return result;
}
分割一张大图为小图片数组
最新推荐文章于 2020-06-03 22:39:01 发布