Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Adding semi-transparent image on BufferedImage

Posted on 2003-10-31
5
Medium Priority
?
693 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

660 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