Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2004

Tip: Looking for answers? Try searching our database.

transparent image background - headless env

Thread view: 
OtisUsenet - 23 Jan 2004 18:00 GMT
Hello,

I am trying to use .java.awt.* classes in a headless (server)
environment to draw an image with a transparent background.

Example: web page with yellow background contains an image with a
black line on it.  I don't want the image to contain a white rectangle
around the black line.  The black line has to sit on the yellow
_web_page_ background.

The code snippet below works fine, but creates an image with a white
background.

 BufferedImage image = new BufferedImage(IMAGE_CANVAS_WIDTH,
                                         IMAGE_CANVAS_HEIGHT,
                                         BufferedImage.TYPE_INT_RGB);
 Graphics2D g2 = image.createGraphics();

 // fill background
 g2d.setColor(Color.white);
 g2d.fillRect(0, 0, IMAGE_CANVAS_WIDTH, IMAGE_CANVAS_HEIGHT);

I tried setting the Color to new Color(255, 255, 255, 255) and also
0,0,0,0, and neither worked.  I can set the background to various
combinations of RGB, but I can't get the background to become
transparent.

Is there a way to do this in a non-Swing environment?

Any help would be appreciated.
Thanks!
ak - 23 Jan 2004 19:10 GMT
>   BufferedImage image = new BufferedImage(IMAGE_CANVAS_WIDTH,
>                                           IMAGE_CANVAS_HEIGHT,
>                                           BufferedImage.TYPE_INT_RGB);
wrong image type - BufferedImage.TYPE_INT_RGB has no alpha!
you need BufferedImage.TYPE_INT_ARGB

____________

http://reader.imagero.com the best java image reader.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.