views:

437

answers:

1

I'm trying to draw a transparent.png image over a TV signal (so blending before rendering is kinda out).

When I was drawing a transparent rect, I could just set SrcOver and specify an alpha for my background color and it would work:

((DVBGraphics) g).setDVBComposite(DVBAlphaComposite.SrcOver);

But now I'm actually trying to use a png with transparency set and that doesn't work (it's just solid).

If I set XOR mode:

g.setXORMode(Color.white);

after setting SrcOver, the entire image becomes translucent, not just the specified dots. Also the parts set to "Transparent" are still visible.

Can anyone point me to the magic set of calls that makes this work?

(Also, swing isn't available--just most of java 1.4).

A: 

I can only suggest you recheck everything; I have painted PNG images using AWT before and it worked fine, just doing the obvious:

private final Image                     image;                                  //

protected void paintForeground(Graphics2D gc, int wid, int hgt) {
    ...
    gc.drawImage(image,dx,dy,(dx+width),(dy+height),0,0,width,height,null);
    ...
    }

This paints with the image transparency honored, except on J2ME 1.1 platforms.

Drawing mode is normal paint, not XOR.

Software Monkey
That seems to have worked better. In the call I was using, I was passing in a color, I guess that color is used to fill the spaces I was hoping would be transparent. Still not sure about the translucent stuff, but thanks!
Bill K