Sign in to follow this  

[java] Java 2D query

Recommended Posts

MangoSupremacy    122
Here's a quick JAVA 2D question. I'm running Wicket and want to dynamically generate/modify images sent to the browser. Wicket supplies the following method to override.
protected boolean render(Graphics2D graphics)
                        try {
                            BufferedImage image = File("C:\\Projets\\randoweb\\src\\com\\tentelemed\\randoweb\\ui\\rando.png"));

                            BufferedImage bi= new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB);
                            Graphics2D g2 = bi.createGraphics();
                            g2.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
                            Rectangle2D.Double rect = new Rectangle2D.Double(0,0,32,32);

                            graphics.drawImage(bi, 0, 0, null);
                        } catch (Exception e) {
				        return true;
However this doesn't display my PNG file with the surrounding transparency. All I get is a black rectangle. Help! Many Thanks Anthony

Share this post

Link to post
Share on other sites
MrWugga    132

What happens when you change the code to this?
(haven't pasted the complete method)

g2.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_OVER, 1.0f));
Rectangle2D.Double rect = new Rectangle2D.Double(0,0,32,32);

As far as I know AlphaComposite.CLEAR draws nothing on the combined image.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this