Hi, i'm currently working on a watermark that is invisible using AlphaComposite class. The problem i'm having now is that i'm unable to extract the watermark out from the image after it is save.
package invisibleWatermark; import java.awt.*; import java.awt.geom.*; import java.awt.image.*; import java.io.*; import javax.imageio.*; import javax.swing.*; public class watermark { static BufferedImage bufferedImage; static void watermark(){ File upImage = new File(mainMenu.txtLoadImage.getText()); if(!upImage.exists()){ JOptionPane.showMessageDialog(null, "Please Select an image to be watermark. "); } else { if (mainMenu.txtInputWatermark.getText().isEmpty()){ JOptionPane.showMessageDialog(null, "Please select a watermark to be use. "); return; } else{ ImageIcon oriImage = new ImageIcon(upImage.getPath()); bufferedImage = new BufferedImage(oriImage.getIconWidth(), oriImage.getIconHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D g2D = (Graphics2D) bufferedImage.getGraphics(); g2D.drawImage(oriImage.getImage(), 0, 0, null); AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f); g2D.setComposite(alpha); g2D.setColor(Color.white); g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2D.setFont(new Font("Arial", Font.BOLD, 35)); String watermark = mainMenu.txtInputWatermark.getText(); FontMetrics fontMetrics = g2D.getFontMetrics(); Rectangle2D rect2D = fontMetrics.getStringBounds(watermark, g2D); g2D.drawString(watermark, (oriImage.getIconWidth() - (int) rect2D .getWidth()) / 2, (oriImage.getIconHeight() - (int) rect2D .getHeight()) / 2); g2D.dispose(); embedPopupMenu.embedConfirmMenu(); } } } }