This commit is contained in:
Looly
2022-07-29 23:05:20 +08:00
parent a36a970341
commit 7769822e11
17 changed files with 237 additions and 27 deletions

View File

@@ -299,7 +299,7 @@ public class BackgroundRemoval {
}
}
final Map<String, Integer> map = new HashMap<>(list.size());
final Map<String, Integer> map = new HashMap<>(list.size(), 1);
for (final String string : list) {
Integer integer = map.get(string);
if (integer == null) {
@@ -309,7 +309,7 @@ public class BackgroundRemoval {
}
map.put(string, integer);
}
String max = "";
String max = StrUtil.EMPTY;
long num = 0;
for (final Map.Entry<String, Integer> entry : map.entrySet()) {
final String key = entry.getKey();
@@ -326,7 +326,7 @@ public class BackgroundRemoval {
return ImgUtil.toHex(Integer.parseInt(strings[0]), Integer.parseInt(strings[1]),
Integer.parseInt(strings[2]));
}
return "";
return StrUtil.EMPTY;
}
// -------------------------------------------------------------------------- private

View File

@@ -1356,6 +1356,19 @@ public class ImgUtil {
return out.toByteArray();
}
/**
* 根据文字创建透明背景的PNG图片
*
* @param str 文字
* @param font 字体{@link Font}
* @param fontColor 字体颜色,默认黑色
* @param out 图片输出地
* @throws IORuntimeException IO异常
*/
public static void createTransparentImage(String str, Font font, Color fontColor, ImageOutputStream out) throws IORuntimeException {
writePng(createImage(str, font, null, fontColor, BufferedImage.TYPE_INT_ARGB), out);
}
/**
* 根据文字创建PNG图片
*