• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 704
  • Last Modified:

Adding semi-transparent image on BufferedImage

I recently wrote a little servlet that adds a semi-transparent copyright message on top of any image displayed on a web-site.
It works pretty well, using the BufferedImage.getGraphics() method and then using Graphics.drawString().

Now the client would like to use their logo instead of a text string as the semi-transparent "watermark".

Can anyone tell me where I could find the proper classes and methods to draw a semi-transparent image (shape) on top of an existing image?

I was looking at Graphics.drawImage(...) and Graphics2D.fill(Shape s)

The former does not seem to offer the capability to specify a transparency and the later would work if I hade a Shape, that specified the borders of the logo.
However, how do I turn their Logo into a Shape object? Is there a way to read a Shape in from an EPS (vector) file or something like it?

Or should I look somewhere else?
0
Bohumil
Asked:
Bohumil
  • 4
1 Solution
 
objectsCommented:
You need to first filter the image you want to add required level of transparency.
0
 
objectsCommented:
Here's an example of how to filter an image:

http://www.javaalmanac.com/egs/java.awt.image/FilterRgb.html?l=find
0
 
objectsCommented:
And then use drawImage() to paint the filtered semi-transparent image onto the destination image.
0
 
BohumilAuthor Commented:
Who'd a thunk It'd be that easy!

Thanks a lot, objects!!!!
0
 
objectsCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now