JAVA编程中g.drawImage(pict, a, b, 50, 50, this);函数出错

来源:互联网 发布:java解析xml文件 编辑:程序博客网 时间:2024/05/22 14:05


try

 {
    src = ImageIO.read(new File(str));
}
 catch(Exception e)
 {
    System.out.println(e);
 }
    newpic = src.getSubimage(0, 0, 50, 50);
      
    pict = newpic;
    int b=W*(i%GameSize)+W;
    int a=W*(i/GameSize)+W;
    g.drawImage(pict, a,  b, 50, 50, this);

其中确保原图像中src中长和宽都有五十,不然会出错。。。。。。。。。。。。。

0 0
原创粉丝点击