package com.thinkgem.jeesite.common.utils;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
/**
* 背景图生成工具类
* by.白名 ykbaiming@outlook.com
*/
public class BackgroundImageSynthesisUtils {
/**
* 合成纯色背景图
*
* @param width 宽度
* @param height 高度
* @param colorCode tgb 颜色代码
* @param outPath 输出路径
* @return
*/
public static boolean createBackgroundImg(Integer width, Integer height, String colorCode, String outPath) {
BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
String[] colorArr = formatColorCode(colorCode);
if (colorArr == null) {
return false;
}
File backgroundImg = new File(outPath);
if (!backgroundImg.exists()) {
backgroundImg.mkdirs();
}
return writeImage
JAVA生成纯色背景图-自定义大小-自定义颜色
最新推荐文章于 2024-03-18 10:49:57 发布