下面图老师小编要跟大家分享用java绘制google中文名称“谷歌”,简单的过程中其实暗藏玄机,还是要细心学习,喜欢还请记得收藏哦!
【 tulaoshi.com - 编程语言 】
  Google发布中文名谷歌,我们来用Java绘制google中文名称“谷歌”,java与google,鱼与熊掌我兼得了。 *_*
  
  
package ccidnet;
  import java.io.*;
  import java.awt.*;
  import java.awt.image.*;
  import com.sun.image.codec.jpeg.*;
  class google {
  public static void main(String[] args) {
  BufferedImage bufferedImage = null;
  Graphics2D graphics2D = null;
  int widths = 100;
  int heights = 100;
  try {
  bufferedImage = new BufferedImage(widths, heights,
  BufferedImage.TYPE_INT_RGB); 
  graphics2D = (Graphics2D) bufferedImage.getGraphics();
  graphics2D.setBackground(java.awt.Color.black);
  graphics2D.setColor(java.awt.Color.green);
  Font font=new Font("",Font.PLAIN,20);
  graphics2D.setFont(font);
  graphics2D.drawString("谷歌", 30, 50);
  font=new Font("",Font.PLAIN,10);
  graphics2D.setFont(font);
  graphics2D.drawString("by 神灯", 60, 85);
  OutputStream outPutStream = new FileOutputStream("c:google.jpg");
  JPEGImageEncoder encoder = JPEGCodec
  .createJPEGEncoder(outPutStream);
  encoder.encode(bufferedImage);
  } catch (Exception e) {
  e.getMessage();
  } finally {
  if (graphics2D != null) {
  graphics2D.dispose();
  }
  }
  }
  }来源:http://www.tulaoshi.com/n/20160219/1618388.html
看过《用java绘制google中文名称“谷歌”》的人还看了以下文章 更多>>