code: public static BufferedImage makeImageTranslucent(BufferedImage source, float opacity) {
        if (opacity == 1) {
           return source;
        }
        BufferedImage translucent = new BufferedImage(source.getWidth(), source.getHeight(), BufferedImage.TRANSLUCENT);
        Graphics2D g = translucent.createGraphics();
        g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity));
        g.drawImage(source, null, 0, 0);
        g.dispose();
        return translucent;
     }
docs: returns a transparent image when opacity &lt; 1
  
  @param source
  @param opacity
  @return