//生成黑色底图
public static void pureColorPictures(String width,String height ) {
//width 生成图宽度
// height 生成图高度
//创建一个width xheight ,RGB高彩图,类型可自定
BufferedImage img=new BufferedImage(width, height , BufferedImage.TYPE_INT_RGB);
//取得图形
Graphics g=img.getGraphics();
//设置颜色
g.setColor(Color.BLACK);
//填充
g.fillRect(0, 0, img.getWidth(), img.getHeight());
//在d盘创建个文件
File file=new File("D:/job/image/top.jpg");
try{
//以png方式写入,可改成jpg其他图片
ImageIO.write(img, "jpg", file);
}catch (IOException e){
e.printStackTrace();
}
java实现生成纯色图片代码实例
最新推荐文章于 2025-07-25 08:35:18 发布
