• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Mike Winters
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Might be worth looking into Java2D graphics.

Steve
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Mike Winters
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic