标签:static cimage system style rgb int users java.awt span
package image; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.Date; import javax.imageio.ImageIO; public class Image { public static void main(String[] args) throws Exception { //缓存位图对象,水平和垂直像素同原始位图 BufferedImage background =new BufferedImage(1078, 1522, BufferedImage.TYPE_INT_RGB); int[] numbers ; BufferedImage srcImage; Graphics2D g; Date date; int width = 1078; int height = 1522; // String text = "008971"; //读取磁盘原始位图 File srcFile = new File("C:/Users/Administrator/Desktop/file/picture/backgroud.jpg"); numbers = new int[5]; for(int i=0;i<numbers.length;i++){ srcImage = ImageIO.read(srcFile); //获取缓存位图的画笔对象 g = srcImage.createGraphics(); g.setColor(Color.red); g.setFont(new Font("宋体", Font.PLAIN, 30)); numbers[i] = i + 1; g.drawImage(srcImage,0,0,width,height,null); g.drawString(String.valueOf(numbers[i]), 489, 486); // ImageIO.write(srcImage, "jpg", new File("C:/Users/Administrator/Desktop/file/picture/"+String.valueOf(numbers[i])+".jpg")); ImageIO.write(srcImage, "jpg", new File("C:/Users/Administrator/Desktop/file/picture/"+System.currentTimeMillis()+".jpg")); //dispose后将BufferedImage的所有资源都释放掉了 g.dispose(); } } }
标签:static cimage system style rgb int users java.awt span
原文地址:https://www.cnblogs.com/celine/p/9460541.html