Change the alpha value of a BufferedImage?

后端 未结 6 1717
清酒与你
清酒与你 2020-12-11 04:21

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)

6条回答
  •  醉话见心
    2020-12-11 04:48

    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.

提交回复
热议问题