龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > JAVA开发 >

用java绘制google中文名称“谷歌”

时间:2009-12-23 15:42来源:未知 作者:admin 点击:
分享到:
Google发布中文名谷歌,我们来用Java绘制google中文名称“谷歌”,java与google,鱼与熊掌我兼得了。 *_* package ccidnet; import java.io.*; import java.awt.*; import java.awt.image.*; import com.sun.image.codec.j

  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();
  }
  }
  }
  }

  
精彩图集

赞助商链接