zoukankan      html  css  js  c++  java
  • Graphics2D画图时背景颜色设置

    package test;

    import java.awt.AlphaComposite;
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.Graphics2D;
    import java.awt.image.BufferedImage;
    import java.io.File;

    import javax.imageio.ImageIO;

    public class DrawGraphics {

     /**
      * @param args
      */
     public static void main(String[] args) throws Exception{
      int width=800;
      int height=800;  
      File file = new File("e:a.jpg");
      BufferedImage bi = new BufferedImage(width, height,
        BufferedImage.TYPE_INT_RGB);//RGB形式
      Graphics2D g2 = (Graphics2D) bi.getGraphics();
      g2.setBackground(Color.WHITE);//设置背景色
      g2.clearRect(0, 0, width, height);//通过使用当前绘图表面的背景色进行填充来清除指定的矩形。
      g2.setPaint(Color.BLUE);//设置画笔,设置Paint属性
      g2.drawOval(0, 0, 80, 80);
      ImageIO.write(bi, "jpeg", file);
      g2.dispose();
      System.out.println("test");

     }

    }

  • 相关阅读:
    Path Sum
    Binary Tree Level Order Traversal II
    Jump Game
    leedcode 刷题-V2
    (2016 年) githup 博客地址 : https://github.com/JMWY/MyBlog
    算法分类总结
    剑指 Offer 题目汇总索引
    LeedCde 题解目录
    趣味算法总目录
    常用
  • 原文地址:https://www.cnblogs.com/waj2018/p/9714861.html
Copyright © 2011-2022 走看看