Skip to main content

alpha transparency not working in png or Color

4 replies [Last post]
rdecker
Offline
Joined: 2009-02-25
Points: 0

I have several images with alpha transparency but the transparency is ignored in the RI. I am using DVBBufferedImage. I also tried drawing using a fill color with tranparency. It seems like instead of making it transparent it is making blacker.

gr.setColor(fillColor);
gr.fillRect(x1, y1, w, h);

This is the graphics object from the log:

20100802 13:54:19.049 INFO RI.Stack.StdOut- Graphics Object: org.cablelabs.impl.dvb.ui.DVBGraphicsImpl2[=java.awt.Font[family=Tiresias,name=Tiresias,style=bolditalic,size=40],color=org.dvb.ui.DVBColor[r=255,g=255,b=255,a=180]]

Is this unsupported in the RI or am I missing something?

Message was edited by: rdecker

Message was edited by: rdecker

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rdecker
Offline
Joined: 2009-02-25
Points: 0

I figured this out. The drawImage is not broken. My code was setting AlphaComposite.Src for all it's drawing methods. I changed it to AlphaComposite.SrvOver and it fixed the issue.

rdecker
Offline
Joined: 2009-02-25
Points: 0

Upon further investigation I've found that the transparency issues appears to be related to this issue:

http://forums.java.net/jive/thread.jspa?messageID=397085&#397085

The images I am drawing use this method:

public abstract boolean drawImage(Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
ImageObserver observer)

It seems transparency does not work in this method.

I didnt' find an issue in the Issue Tracker related to this as mentioned in the earlier post. Is this something that is going to be fixed?

rdecker
Offline
Joined: 2009-02-25
Points: 0

It seems there was a bug fix https://ocap-ri.dev.java.net/issues/show_bug.cgi?id=41 that fixed this issue in an earlier OCAP-RI release but it got unfixed in the latest release. I am using 1.1.4 REL B 9797 and the DVBGraphics in the ocap-stub.jar extends Graphics and not Graphics2D as corrected by the fix.

The javadocs also show DVBGraphics extended from Graphics as well. It appears to be correct in ocap-classes.jar (runtime).

As a workaround to being able to reference DVBGraphics with a Graphics2D in my code I pulled the updated source file for DVBGraphics from svn, and added it to my project.

rdecker
Offline
Joined: 2009-02-25
Points: 0

I also tried using org.dvb.ui.DVBColor, which is supposed to support transparency and it only changes the shade of the color darker or lighter.

Reading http://www.mhp-interactive.org/tutorials/ocap/graphics the section on High-Level Graphics Issues says you can use java.awt.Image for images. Further on the section on Colors and Transparency says Java 1.1 Color doesn't support transparency (although it seems the RI is using Java 1.4) and says to use the DVBColor.

Do I need to request a graphics configuration with some specification for transparency?

I see methods in HGraphicsConfiguration to get a punch through color but it says punching through to the background with the aforementioned document says is optional in OCAP and isn't really what I am looking for anyway.