This article describes the method of obtaining image pixels by Java. Share it for your reference, as follows:
package cn.net.comsys.sso;import java.awt.image.BufferedImage;import javax.imageio.ImageIO;import java.io.*;public class Test {publ ic 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.getWi dth(); / / Pixel int height = bi.getHeight(); // Pixel System.out.println("width=" + width + ",height=" + height + ".");}}
I hope this article will be helpful to everyone's Java programming.