Java BufferedImage Operation makeImageTranslucent(BufferedImage source, float alpha)

Here you can find the source of makeImageTranslucent(BufferedImage source, float alpha)

Description

make Image Translucent

License

Apache License

Declaration

public static BufferedImage makeImageTranslucent(BufferedImage source, float alpha) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.awt.*;

import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage makeImageTranslucent(BufferedImage source, float alpha) {
        BufferedImage target = new BufferedImage(source.getWidth(), source.getHeight(),
                java.awt.Transparency.TRANSLUCENT);
        // Get the images graphics
        Graphics2D g = target.createGraphics();
        // Set the Graphics composite to Alpha
        g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
        // Draw the image into the prepared reciver image
        g.drawImage(source, null, 0, 0);
        // let go of all system resources in this Graphics
        g.dispose();//from   w  w  w.  ja va2s . c  om
        // Return the image
        return target;
    }
}

Related

  1. knit(BufferedImage[] buffImages)
  2. layer(BufferedImage source, BufferedImage destination, int x, int y)
  3. makeBinary(BufferedImage image, int threshold)
  4. makeCursor(BufferedImage img, int hotx, int hoty, String name)
  5. makeGhost(BufferedImage image)
  6. makeItBlack(BufferedImage image)
  7. makeMouseover(final BufferedImage src)
  8. makeOpaque(BufferedImage img, Color col)
  9. MakePoly(BufferedImage spr, int d, int angle, int baseX, int baseY)