Commit de6434db authored by 周健威's avatar 周健威

修改代码

parent 2512298a
......@@ -24,7 +24,7 @@ public class ImageWatermarkUtil {
// 水印文字大小
public static final int FONT_SIZE = 28;
// 水印文字字体
private static Font font = new Font ("微软雅黑", Font.BOLD, FONT_SIZE);
private static Font defaultFont = new Font ("微软雅黑", Font.BOLD, FONT_SIZE);
// 水印文字颜色
private static Color color = Color.white;
// 水印之间的间隔
......@@ -56,7 +56,7 @@ public class ImageWatermarkUtil {
*/
public static void ImageByText (String logoText, String srcImgPath, String targerPath) throws IOException {
Image srcImg = ImageIO.read (new File (srcImgPath));
ImageByText (logoText, srcImg, targerPath, null);
ImageByText (logoText, srcImg, targerPath, null, null);
}
/**
......@@ -68,7 +68,10 @@ public class ImageWatermarkUtil {
* @param targerPath
* @param degree
*/
public static void ImageByText (String logoText, Image srcImg, String targerPath, Integer degree) {
public static void ImageByText (String logoText, Image srcImg, String targerPath, Integer degree, Font font) {
if(null == font){
font = defaultFont;
}
InputStream is = null;
OutputStream os = null;
......
......@@ -98,7 +98,7 @@ public class UploadService {
//将文件写入指定位置
//ImgUtil.write(newImage2, new File(filePath));
ImageWatermarkUtil.ImageByText(dto.getContext(), newImage, filePath, dto.getDegree());
ImageWatermarkUtil.ImageByText(dto.getContext(), newImage, filePath, dto.getDegree(), font);
//将文件写入指定位置
//FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment