コード例 #1
0
ファイル: JCanvas.java プロジェクト: xaleth09/Connect4-AI
 public static BufferedImage tileImage(BufferedImage im, int width, int height) {
   GraphicsConfiguration gc =
       GraphicsEnvironment.getLocalGraphicsEnvironment()
           .getDefaultScreenDevice()
           .getDefaultConfiguration();
   int transparency = Transparency.OPAQUE; // Transparency.BITMASK;
   BufferedImage compatible = gc.createCompatibleImage(width, height, transparency);
   Graphics2D g = (Graphics2D) compatible.getGraphics();
   g.setPaint(new TexturePaint(im, new Rectangle(0, 0, im.getWidth(), im.getHeight())));
   g.fillRect(0, 0, width, height);
   return compatible;
 }
コード例 #2
0
 /**
  * Creates the image to cache. This returns a translucent image.
  *
  * @param c Component painting to
  * @param w Width of image to create
  * @param h Height to image to create
  * @param config GraphicsConfiguration that will be rendered to, this may be null.
  */
 @Override
 protected Image createImage(Component c, int w, int h, GraphicsConfiguration config) {
   if (config == null) {
     return new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
   }
   return config.createCompatibleImage(w, h, Transparency.TRANSLUCENT);
 }