This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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?
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
Joined: Jun 09, 2005
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.