|
@@ -27,8 +27,8 @@ public class ImageBuildUtil {
|
|
* @throws FileNotFoundException
|
|
* @throws FileNotFoundException
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
- public static BufferedImage buildTagImage(BufferedImage image, List<PictureTag> tags)
|
|
|
|
- throws FileNotFoundException, IOException {
|
|
|
|
|
|
+ public static BufferedImage buildTagImage(BufferedImage image, List<PictureTag> tags) throws FileNotFoundException,
|
|
|
|
+ IOException {
|
|
if (tags != null && !tags.isEmpty()) {
|
|
if (tags != null && !tags.isEmpty()) {
|
|
BufferedImage newImg = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
|
|
BufferedImage newImg = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
|
|
Graphics2D g = newImg.createGraphics();
|
|
Graphics2D g = newImg.createGraphics();
|
|
@@ -39,8 +39,12 @@ public class ImageBuildUtil {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
int fontSize = tag.getSize() > 0 ? tag.getSize() : DEFAULT_FONT_SIZE;
|
|
int fontSize = tag.getSize() > 0 ? tag.getSize() : DEFAULT_FONT_SIZE;
|
|
- int left = Math.max(fontSize, tag.getLeft());
|
|
|
|
- int top = Math.max(fontSize, tag.getTop());
|
|
|
|
|
|
+ if (tag.getLeft() <= 1 || tag.getTop() <= 1) {
|
|
|
|
+ tag.setLeft(tag.getLeft() * image.getWidth());
|
|
|
|
+ tag.setTop(tag.getTop() * image.getHeight());
|
|
|
|
+ }
|
|
|
|
+ int left = (int) Math.max(fontSize, tag.getLeft());
|
|
|
|
+ int top = (int) Math.max(fontSize, tag.getTop());
|
|
g.setFont(new Font(DEFAULT_FONT_NAME, Font.PLAIN, fontSize));
|
|
g.setFont(new Font(DEFAULT_FONT_NAME, Font.PLAIN, fontSize));
|
|
for (String content : tag.getContent()) {
|
|
for (String content : tag.getContent()) {
|
|
g.drawString(content, left, top);
|
|
g.drawString(content, left, top);
|