java如何用图片填充不规则图形?
没有思路啊。HELP!

解决方案 »

  1.   

    java.awt.TexturePaint
    TexturePaint 类提供一种用被指定为 BufferedImage 的纹理填充 Shape 的方式。因为 BufferedImage 数据由 TexturePaint 对象复制,所以 BufferedImage 对象的大小应该小一些。在构造时,纹理定位在用户空间中指定的 Rectangle2D 的左上角。计算纹理在设备空间中的位置的方式是,在用户空间中的所有方向上无限制地总体复制指定 Rectangle2D,然后将 BufferedImage 映射到各个复制的 Rectangle2D。
      

  2.   

    BufferedImage img//要填充图片
    TexturePaint tp = new TexturePaint(img, new Rectangle2D());//Rectangle2D是img大小
    g2D.setPaint(tp);//g2D画笔
    g2D.fill(area);//area不规则图形
    这样就能实现用img来填充不规则形状,