How to add Transparency level for pictures?

  • Michael Ribeiro

    Michael Ribeiro - 2012-10-10

    I have 2 png pictures which lie one on the other. I want that the first picture becomes a litte transparent so that it is possible to see better the background picture. Background color of first is white.

    I do not want totally transparency because the background color is used to increase contrast.

    It is possible to level the transparency of pictures with this API?
    How I can do this?

  • Elfi Heck

    Elfi Heck - 2012-10-11

    You'll probably want to add a mask to your image. To get only a shine through effect without full transparency you use a so called soft mask. For an image this is a second PDImage with DeviceGray color space that is assigned to the first PDImage with setSMask(). The gray values determine the level of transparency you get. The second image doesn't have to have the same size as the other one, it will be scaled to fit. This means to get the same transparency for the whole image a mask image of size 1x1 is enough.
    See sections 4.8.5 (Masked Images) and 7.5.4 (Specifying Soft Masks) in the PDF reference for more information.

    Side note: the DrawImage example in the jPodRenderer project will create a soft masked image if you feed it an image file with an alpha channel.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks