NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Easy Java Simulations (2001- ) => Questions related to EJS => Topic started by: Abyss333 on October 24, 2010, 11:40:54 pm



Title: Need help with transparency of images
Post by: Abyss333 on October 24, 2010, 11:40:54 pm
Hello!

Right now I am programming a little game with a friend and there's a little problem with the transparency of images.
At the moment we've got a background and a protagonist, both as an image on our drawing panel.
Now the protagonist is a 20x15 pixel image and the unused pixel spots are still white.
Well these unused pixels in this image are visible on the background of course so there's always a rectangular white frame around our character.
Of course I could use PNGs which already got the transparency but GIFs for example are quite smaller.

In other pixelart games I saw a (mostly) very extreme color as a background in the spritesand somehow this was not be seen in the later background. So somehow the programm recognized this color and replaced it with the color of the real background beneath it.
Maybe that would be a nice approach but I really cannot figure it out myself

Thanks already for help  :)


Title: Re: Need help with transparency of images
Post by: Fu-Kwun Hwang on October 25, 2010, 09:32:08 am
It is different between white color and no color at all.

White Color =new java.awt.Color(255,255,255,255)

If the background of your image file is white, then all the color behind your image file will be blocked by the image file.
If there is no color added to the background of your image file, the color behind your image file can be shown as background.


Try to set the transparent parameter for the background color in your image file to 0 ,
then all the color behind the image will not be blocked by the background color in your image file.


Title: Re: Need help with transparency of images
Post by: lookang on October 26, 2010, 02:26:21 pm
i used  Gimp http://www.gimp.org/ to make the background transparent and save as png.

you can check out http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1501.0 which i remove the background of the planets by cropping in Gimp

good luck!