⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imagedivision.java

📁 Java版拼图游戏
💻 JAVA
字号:
/*
 * @(#)ImageDivision.java 1.0 03/08/22
 * Copyright 2003 Entao Zhang, All rights reserved.
 */

import java.awt.*;
import java.awt.image.*;
import javax.swing.ImageIcon;

/**
 * 图象分割算法之--长方形分割
 */
public class ImageDivision{
	public ImageIcon[] Division(Image img,int x,int y,Component observer){
		int w=img.getWidth(null);
		int h=img.getHeight(null);
		int cellw=w/x;
		int cellh=h/y;
		ImageIcon cell[]=new ImageIcon[x*y];
		CropImageFilter cif;
		FilteredImageSource fis;
		int ci;
		for (int j=0; j<y; j++) {
			for (int i=0; i<x; i++) {
				cif=new CropImageFilter(cellw*i,cellh*j,cellw,cellh);
				fis=new FilteredImageSource(img.getSource(),cif);
				ci=j*x+i;
				cell[ci]=new ImageIcon(observer.createImage(fis));
			}
		}
		return cell;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -