我需要找到一种方法来计算图像的长度和宽度(这是一个.jpg)我有文件的长度,但它没有用,因为我想创建一个数组来存储有关每个我正在使用的图像文件的像素。如何在java中获得jpg的像素尺寸?
public void getImageData(){
File f= new File("myPicture.jpg");
this.length = (int) f.length();
System.out.println("length of file = " + length);
BufferedImage image = null;
try {
image = ImageIO.read(f);
}
catch (IOException e) {
e.printStackTrace();
}
非常感谢!
可能的重复http://stackoverflow.com/questions/1559253/java-imageio-getting-image-dimension-without-reading-the-entire-file – 2012-07-11 20:51:46