Solved

Adding semi-transparent image on BufferedImage

Posted on 2003-10-31
5
688 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
Comment Utility
You need to first filter the image you want to add required level of transparency.
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
Comment Utility
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
Comment Utility
And then use drawImage() to paint the filtered semi-transparent image onto the destination image.
0
 

Author Comment

by:Bohumil
Comment Utility
Who'd a thunk It'd be that easy!

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

Expert Comment

by:objects
Comment Utility
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now