水印图黑边问题
This commit is contained in:
@@ -77,9 +77,11 @@ public class ImageWatermarkUtil {
|
||||
int width = original.getWidth();
|
||||
int height = original.getHeight();
|
||||
|
||||
BufferedImage output = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
BufferedImage output = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2d = output.createGraphics();
|
||||
try {
|
||||
g2d.setBackground(Color.WHITE);
|
||||
g2d.clearRect(0, 0, width, height);
|
||||
g2d.drawImage(original, 0, 0, width, height, null);
|
||||
|
||||
int baseFontSize = Math.max(12, (int) (Math.min(width, height) * watermarkProperties.getFontSizeRatio()));
|
||||
@@ -90,6 +92,7 @@ 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());
|
||||
|
||||
Reference in New Issue
Block a user