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中长和宽都有五十,不然会出错。。。。。。。。。。。。。