ITeye博客

JAVA获得图片像素

java110eye · 2011-08-03 14:33 · 服务器端代码块 · 编程语言 · Markdown

package cn.net.comsys.sso;

import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.*;

public class Test {
	public static void main(String args[]) {

		File file = new File("a.bmp");
		BufferedImage bi = null;
		try {
			bi = ImageIO.read(file);
		} catch (Exception e) {
			e.printStackTrace();
		}

		int width = bi.getWidth(); // 像素
		int height = bi.getHeight(); // 像素
		System.out.println("width=" + width + ",height=" + height + ".");

	}

}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。