已经用drawImange画出一张图片,现想把它平均切割成几块,存入一个Imange数组,需要的时候一块一块画出来。不知道我说清楚没有,就是好比做拼图游戏,把一张图片分成几个Imange保存
找来找去,Graphics里只有一个create(int x, int y, int width, int height)函数可以把指定的区域另存为一个Graphics。可是怎么转化成把它转化成Image呢?

解决方案 »

  1.   

    这两个方法
    clipRect(int x, int y, int width, int height) 
    setClip(int x, int y, int width, int height)
      

  2.   

    使用 BufferedImage 的,就可以了,很简单的. 
    BufferedImage getSubimage(int x, int y, int w, int h) 
              Returns a subimage defined by a specified rectangular region.
      

  3.   

    to alabaza:
       clipRect和setClip我也看到了,但是它们并不返回Image值啊to abcdhy(程旭):
       谢谢,我试一下