wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Is this even possible in Java? Overlaying multiple images with alpha channels Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Is this even possible in Java? Overlaying multiple images with alpha channels" Watch "Is this even possible in Java? Overlaying multiple images with alpha channels" New topic
Author

Is this even possible in Java? Overlaying multiple images with alpha channels

Mike Winters
Greenhorn

Joined: Jun 09, 2005
Posts: 14
I've got a homework assignment due soon, but the requirements are pretty broad. One of my ideas for meeting all the requirements involves overlaying multiple images with alpha channels (transparency).

To be more specific, I am thinking about making an application to choose the color and pattern of a skydiving jumpsuit. The colors will be chosen by three slider bars for the suit color, and three for the trim pattern. The only way I can think to do this is overlaying three images with alpha channels, and then making those images color channels correspond to the color selected by the user.

In other words, the first image will be a rectangle of a solid color, selected by the slider controls. The second image will overlay onto that, and will be of a different color. The transparency of the second image will be determined by the pattern selected, but the color will be chosen by another set of sliders. The third (and final) image will be a cutout of the suit shape, essentially a stick figure with thick body. The stick figure part itself will be transparent, and the rest will be white (background color of the application). This SHOULD give the impression that it is a single image, and the component parts of the suit can be changed independently.

Is this even possible in Java, and if so, are there any special classes I should look into, or can it be done using just JLabels with images that have the correct alpha channels?

Thanks,

Mike
Steve McCann
Ranch Hand

Joined: Oct 20, 2004
Posts: 81
Might be worth looking into Java2D graphics.

Steve
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
It is possible in Java, but I have the feeling that there should be a better solution. Why don't you just calculate the Color from the three slider values and draw a rectangle of that color?

Anyway, moving to Swing/AWT...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Mike Winters
Greenhorn

Joined: Jun 09, 2005
Posts: 14
The sliders WILL determine the color, but drawing a rectangle won't really work, as I kinda need the user to see the shape of the suit and the design. While it is not a requirement for my homework project, it would just look so much better if the suit color actually changes, rather than having a JPanel that I just change the background color of.

The only reason I posted here rather than just trying it myself wa due to a severe lack of time. I searched several forums here for "transparent image" and "alpha channel" and "image overlay", but did not get many results. I'm certainly not looking for any of you to do it for me, just wondering if my idea will even work.

I'll look inot the Java2D classes when I get home from work today.

Thanks,

Mike
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is this even possible in Java? Overlaying multiple images with alpha channels
 
Similar Threads
changing gray pixels....
Longer Post - ALL IBM ICE EXAM Q's for UML
Alpha Channeling
Why did it have to be PNG
Java paint question