Li Wu:
Learn to think more, honouring teachers save Thanksgiving. Leaf See Root 321, rivers with one.
Meekness Conscience Lord, willing to do without regrets to the most bitter. Reading exercise strong body and mind, Prudential advised and the line and cherish.
Os:windows7 x64
Jdk:jdk-8u131-windows-x64
Ide:eclipse Oxygen Release (4.7.0)
Code
Package Jizuiku.image;import Java.awt.color;import Java.awt.font;import java.awt.graphics2d;import Java.awt.image.bufferedimage;import Java.io.filenotfoundexception;import Java.io.fileoutputstream;import Java.io.ioexception;import javax.imageio.imageio;/** * AWT generates a rectangular picture and writes the string inward * * @author to the bitter * @version V17.10.18 */public C Lass Createimagedemo {public static void main (string[] args) throws FileNotFoundException, IOException {//Get picture buffer int Widt H = 100;int height = 50;int ImageType = BUFFEREDIMAGE.TYPE_INT_BGR; BufferedImage myimage = new BufferedImage (width, height, imageType);//Get brush graphics2d pen = (graphics2d) myimage.getgraph ICS ();//Set the color of the pen, that is, the background color pen.setcolor (color.white);//Draw a rectangle//coordinate x coordinate y width 100 length of pen.fillrect (0, 0, 100, 50);//Microsoft JAS Black Bold display size 1 2Font font = new Font ("Microsoft Jas Black", Font.Bold);p en.setfont (font);//The Color of the word and background of the color to be different//to the most bitter for the first time did not notice, the results ran three or four times found no word ah pen.s Etcolor (Color.Blue);//write Pen.drawstring ("ABCD", ",") Imageio.write (MyImage, "JPEG", New FileOutputStream ("e:\\ A.jpg "));}}
Effect
Java is good, worth learning.
Learning resources: Itcast and Itheima Video library. If you have public resources, can share to me, with your resources to learn can also
Blog post is to watch the video, into thinking written. It's good that the teacher speaks well. Blog bad, is to give the most bitter not serious.
Java Foundation AWT generates a rectangular picture and writes the string inward