Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Adding semi-transparent image on BufferedImage

Posted on 2003-10-31
5
Medium Priority
?
696 Views
Last Modified: 2007-12-19
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
Comment
Question by:Bohumil
  • 4
5 Comments
 
LVL 92

Expert Comment

by:objects
ID: 9661284
You need to first filter the image you want to add required level of transparency.
0
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 9661289
Here's an example of how to filter an image:

http://www.javaalmanac.com/egs/java.awt.image/FilterRgb.html?l=find
0
 
LVL 92

Expert Comment

by:objects
ID: 9661326
And then use drawImage() to paint the filtered semi-transparent image onto the destination image.
0
 

Author Comment

by:Bohumil
ID: 9667145
Who'd a thunk It'd be that easy!

Thanks a lot, objects!!!!
0
 
LVL 92

Expert Comment

by:objects
ID: 9667271
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question