java.awt.Toolkit kit = Toolkit.getDefaultToolkit();
try {
java.awt.Image img,ig;
img = kit.getImage("/home/aditya/Pictures/tile.png");
ig =
javax.imageio.ImageIO.read(
new java.io.File("/home/aditya/Pictures/tile.png"));
}
int w = img.getWidth(null);
int wp = ig .getWidth(null);
int h = img.getHeight(null);
int hp = ig .getHeight(null);
System.out.println(wp+" "+hp+" "+w+" "+h);
总是给出这个输出
59 64 -1 -1
即通过工具包创建的图像的宽度、高度总是返回-1。
任何想法 ?