I have a question regarding setting the Alpha value of pixels in a window of a 
Java desktop application running under Linux.  A simplified version of the code 
from my paint function is shown below:

public void paint(Graphics g) {

        int alpha;
        Graphics2D g2d = (Graphics2D) g;

        Composite c = AlphaComposite.getInstance(AlphaComposite.SRC_OVER);
        g2d.setComposite(c);

        // Draw transparent rectangle
        alpha = 128;
        g2d.setPaint(new Color(0, 0, 255, alpha));
        g2d.fill(new Rectangle(0, 0, 100, 100));

        // Draw opaque rectangle
        alpha = 255;
        g2d.setPaint(new Color(0, 0, 255, alpha));
        g2d.fill(new Rectangle(100, 0, 100, 100));
}

I am using Graphics2D to draw rectangles with different values of alpha.  Now, 
what I am really trying to do is change the alpha value of pixels in the 
window, however, what appears to be happening is that the alpha value I specify 
is used for the drawing operation and then discarded.  

Just as background info, I use the application window in another program that 
exploits the Composite extension of the X server.  This program redirects the 
window and performs some additional processing based on the alpha value of 
pixels in the window.  If I draw the graphics using X then the alpha value of 
pixels in the window is modified but not when I use Java.

To summarise my question, is there a way in Java to modify the alpha value of 
pixels in a window?

Thanks for looking at my post, any advise or suggestions gratefully received.

Steve
[Message sent by forum member 'spriest' (spriest)]

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

===========================================================================
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