水印添加失败问题

This commit is contained in:
litianxiang
2026-06-02 11:43:07 +08:00
parent a631b80598
commit 9a3cd742c1

View File

@@ -77,7 +77,7 @@ public class ImageWatermarkUtil {
int width = original.getWidth();
int height = original.getHeight();
BufferedImage output = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
BufferedImage output = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = output.createGraphics();
try {
g2d.setBackground(Color.WHITE);
@@ -92,7 +92,6 @@ public class ImageWatermarkUtil {
g2d.setColor(new Color(rgba[0], rgba[1], rgba[2], rgba.length > 3 ? rgba[3] : 128));
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
double radians = Math.toRadians(watermarkProperties.getRotationDegrees());
int stepX = (int) (baseFontSize * watermarkProperties.getSpacingRatioX());