Here you can find the source of changeTranslucentImage(BufferedImage img, float transperancy)
Parameter | Description |
---|---|
url | a parameter |
transperancy | a parameter |
public static BufferedImage changeTranslucentImage(BufferedImage img, float transperancy)
//package com.java2s; //License from project: Apache License import java.awt.AlphaComposite; import java.awt.Graphics2D; import java.awt.image.BufferedImage; public class Main { private static BufferedImage bimg; private static Graphics2D g2; /**//from w w w .j a v a2 s . c om * Change a image with a certain transparency. * * @param url * @param transperancy * @return BufferedImage */ public static BufferedImage changeTranslucentImage(BufferedImage img, float transperancy) { bimg = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TRANSLUCENT); g2 = bimg.createGraphics(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, transperancy)); g2.drawImage(img, null, 0, 0); g2.dispose(); return bimg; } }