| | |
| | | g2d.drawString(watermarkText, x1, y1); |
| | | alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f); |
| | | g2d.setComposite(alphaComposite); |
| | | String extraInfo = String.format("Lon:%.9f Lat:%.6f\n%s 时间:%s", lng, lat,angel,sd); |
| | | String extraInfo = String.format("Lon:%.7f Lat:%.7f\n%s %s", lng, lat,angel,sd); |
| | | |
| | | File fontFile = new File("/tmp/jave/MiSans-Normal.ttf"); // 替换为你的字体文件路径 |
| | | Font customFont = Font.createFont(Font.TRUETYPE_FONT, fontFile).deriveFont(36.00F); |
| | |
| | | int y2 = originalImage.getHeight() - textHeight - 30; // 最底部位置 y 坐标 |
| | | |
| | | |
| | | int rectX = originalImage.getWidth() - textWidth +530; |
| | | int rectX = originalImage.getWidth() - textWidth +490; |
| | | int rectY = originalImage.getHeight() - textHeight -15; |
| | | // 绘制半透明黑色背景矩形 |
| | | Color semiTransparentColor = new Color(0, 0, 0, 156); // 0-255 的 alpha 值,0 表示完全透明,255 表示完全不透明 |
| | | g2d.setColor(semiTransparentColor); |
| | | g2d.fillRect(rectX, rectY, textWidth, textHeight-6); |
| | | |
| | | int rectXs = originalImage.getWidth() - textWidth +450 ; |
| | | int rectXs = originalImage.getWidth() - textWidth +420 ; |
| | | int rectYs = originalImage.getHeight() - textHeight -62; |
| | | // 绘制半透明黑色背景矩形 |
| | | g2d.setColor(semiTransparentColor); |
| | |
| | | // 释放 Graphics2D 对象 |
| | | g2d.dispose(); |
| | | // 保存添加水印后的图片 |
| | | File outputFile = new File("src/main/copy.jpeg"); |
| | | File outputFile = File.createTempFile("mark", ".jpg"); |
| | | |
| | | try { |
| | | ImageIO.write(originalImage, "jpg", outputFile); // 将图像写入临时文件 |
| | | } catch (IOException e) { |