谁知道在canvas面板上面得到一张图片的坐标??
[code=Jav]
public Img extends Canvas{
protected void paint(Graphics g) {
g.drawImage(img, this.getWidth()/2, 10, Graphics.HCENTER|Graphics.TOP) ;
}
}
[/code]
那怎么得到img的坐标??
------解决方案--------------------------------------------------------
[code=Jav]boolean drawImage(Image img, int x, int y, ImageObserver observer)
boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) [/code]
所以image起始点x,y
------解决方案--------------------------------------------------------
draw中不是指明了吗?this.getWidth()/2, 10
没有getX(),getY()函数,一般是通过变量x,y获取,或者从一个封装为bean类中获取