Image img=new ImageIcon(String fileName).getImage();Images that are created from a URL or filename are preloaded using MediaTracker to monitor the loaded state of the image. so you can get the width and height of img, because it has been loaded.
解决方案 »
- 麻烦帮忙看下这个程序出现什么问题了呢?运行是报“出错啦!”
- 请问哪里可以下载 eclipse ????
- 应该是个常见问题!!启动BDK加载buttons.jar失败
- 两个DataInputStream型,如果加起来成一个DataInputStream?还有String型如果转成DataInputStream?
- 关于java程序中运行shell命令的问题
- 关于包的问题,在线等待
- 怎样显示类似JBuilder里的提示功能?
- Java 2D OR Java 3D
- 怎样修改*.jar文件,使之成为一个双击后可以运行的应用程序
- 一个简单的问题,java的路径
- 基本语法问题 关于String的
- 字符串越界的问题
public class JPGSize {
private int intWidth;
private int intHeight;
public JPGSize(String strFileName) {
ImageIcon imageA = new ImageIcon(strFileName);
intWidth=imageA.getIconWidth();
intHeight=imageA.getIconHeight();
}
/**
Description: 取得图片的宽度。
当返回值是"-1"时,表示图片格式错误或文件不存在
*/
public int getWidth() {
return intWidth;
}
/**
Description: 取得图片的高度
当返回值是"-1"时,表示图片格式错误或文件不存在
*/
public int getHeight() {
return intHeight;
} /*
public static void main(String[] args) {
JPGSize JPGSize1 = new JPGSize(args[args.length]);
}
*/
}