诸君请看,这个是图,我想让这个字变得更加的大,应该要怎么做呢?下面是代码
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Random;
import javax.imageio.ImageIO;
public class CheckingCode
{
int width = 200 ;
int height = 140 ;
BufferedOutputStream bos = null ;
Random ran ;
BufferedImage bi ;
Graphics gra ;
StringBuilder sb ;
public void doPost ()
{
String code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" ;
sb = new StringBuilder ("") ;
ran = new Random () ;
bi = new BufferedImage (width,height,BufferedImage.TYPE_INT_RGB) ;
gra = bi.getGraphics() ;
gra.setColor(Color.white) ;
gra.fillRect(0,0,width,height) ;
for(int i = 0 ; i < 4 ; i ++)
{
Character ch = code.charAt(ran.nextInt(code.length()+1)) ;
sb.append(ch) ;
gra.setColor(Color.BLACK) ;
gra.drawString(ch.toString(),25*i+30,70) ;
}
try
{
bos = new BufferedOutputStream (new FileOutputStream (new File ("image//1.jpg"))) ;
ImageIO.write(bi,"jpg",bos) ;
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
try
{
if(bos!=null)
bos.close() ;
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public CheckingCode ()
{
doPost () ;
}
public static void main(String[] args)
{
// TODO Auto-generated method stub
new CheckingCode () ;
}
}
只要改包名就可以了。
如果太麻烦的话,只需要给些小hints给我就好了:》不用特意写一段给我:》(当然如果写了我也会笑纳的)