如何获得图片的高和宽??
我调用img.getWidth(this),单步调试发现返回值是-1。。以下是代码:
程序代码:
public MyPanel( String path, int row, int col, int fw, int fh ) { img = this.getToolkit().getImage(path); /* load picture */ this.GetUnitSize(); } private void GetUnitSize() { this.sw = this.img.getWidth(this) / this.col; this.sh = this.img.getHeight(this) / this.row; System.out.println( sw + " " + sh ); }
大家帮帮忙,我都搞了快两小时了,郁闷死了