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