Change the alpha value of a BufferedImage?

bufferedimage, graphics, java

Solution

I don't believe there's a single simple command to do this. A few options:

- copy into another image with an AlphaComposite specified (downside: not converted in place)

- directly manipulate the raster (downside: can lead to unmanaged images)

- use a filter or BufferedImageOp

The first is the simplest to implement, IMO.

Problem

How do I change the global alpha value of a BufferedImage in Java? (I.E. make every pixel in the image that has a alpha value of 100 have a alpha value of 80)

Original source