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

📄 split.java

📁 自己做的一个小软件
💻 JAVA
字号:
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;

//Singleton class
public class Split
{
	public static final int HARD = 0;
	public static final int NORMAL = 1;
	public static final int EASY = 2;
	public static final String pvo = "png";
	public static final int [] level = {
		20, 40, 60
	};

	private static Split Ob;

	private String filename;
	private String path;

	private Split() {}

	public static Split get()
	{
		if (Ob == null)
			Ob = new Split();
		return Ob;
	}

	public boolean set(String fn)
	{
		filename = fn;
		path = Arg.path + "/" + filename;
		File file = new File(path);

		return file.exists();
	}

	public BufferedImage[][] divid(int type)
	{
		try
		{
			if (filename == null)
				return null;

			BufferedImage image = ImageIO.read(new File(path));
			int len = level[type];
			int cal = image.getWidth() / len;
			int row = image.getHeight() / len;
			BufferedImage [][] subimage = new BufferedImage[row][cal];

			for (int i = 0; i < row; i++)
				for (int j = 0; j < cal; j++)
					subimage[i][j] = image.getSubimage(j*len, i*len, len, len);

			return subimage;
		}
		catch (Exception e)
		{
			return null;
		}
	}
}

⌨️ 快捷键说明

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