首页 > 编程 > Java > 正文

java编程简单获取图片像素的方法

2019-11-26 14:51:02
字体:
来源:转载
供稿:网友

本文实例讲述了java获取图片像素的方法。分享给大家供大家参考,具体如下:

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 + ".");}}

希望本文所述对大家Java程序设计有所帮助。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表