Just to clarify the response below - saying "when another thread creates a new Graphic Context" is a bit of a red herring as each object returned from BufferedImage.getGraphics() or BufferedImage.createGraphics() is a brand new object regardless of which thread is calling the method.

Every Graphics object you get from a BufferedImage will have a default initial foreground color of white and a default background color of black. You can change this with setColor() and setBackground(), and those settings will be carried over into cloned graphics objects you get from the Graphics.create() and Graphics.create(x,y,w,h) methods, but they will have no effect on the objects returned from the getGraphics() and createGraphics() methods, regardless of which thread calls them...

                        ...jim

jav...@javadesktop.org wrote:
Hi Karys,

I'm dealing with the same problem.

When doing a bufferdImage.clearRect() , all pixels of the bufImage are set to 
the BackgroundColor --white in your case. You can set the backgroundColor using 
the Graphic Context of the Image.  however, when another thread creates a new 
Graphic Context, the backgroundColor will still be white.
I couldn't find any way to set the BackgroundColor of a BufferedImage 
permanently.
If you did, please let me know !

Cheers,
Mark

Image image=  new BufferedImage(width,height,BufferedImage.TYPE_INT_ARGB);
Graphics g = image.getGraphics();
        if( g instanceof Graphics2D ){
               Graphics2D g2d = (Graphics2D) g;
                // make sure the background is filled with transparent pixels 
when cleared !
                g2d.setBackground(new Color(0,0,0,0));
                
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_IN, 0.0f));
        }
[Message sent by forum member 'mark_minnoye' (mark_minnoye)]

http://forums.java.net/jive/thread.jspa?messageID=324664

===========================================================================
To unsubscribe, send email to lists...@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
lists...@java.sun.com and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to lists...@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
lists...@java.sun.com and include in the body of the message "help".

Reply via email to