pcx, tga or bmp. Any existing code for PROFESSIONAL use out there?

I am developing a 2D Hexagon Wargame and need to have transparency and shadowing i.e need to use pcx, tga or bmp. Is there any existing easily used code for this for professional use?

I heard of JIMI, but I am not sure it is for professional use.

Also, do the image formats all work the same on different platforms?

you need to use that format becouse of transparancy / shadowing or you just need to use them? Why those formats?
Only thing I actually have to say it’s that transparancy is supported in gifs and translucency in pngs.

I need them for transparency and Shadowing.

Just use a format which supports transparency. Eg for bitmask transparency you can use gif or 8bit pngs. For full alpha you can use 32bit pngs.

Using #FF00FF as color for the transparent areas is a very dated workaround for getting bitmask transparency into formats which doesnt support that by itself.

Ok, Onyx. But how do I use those formats?

Currently i use the Toolkit.getDefaultToolkit().getImage(String) but that only works for jpg or gif.

I saw a topic about ImageIO here ->
http://www.java-gaming.org/forums/index.php?topic=6952.0

but it has alot of classes like BufferedImage, ImageLoader, … to fully grip before proceeding. How do i code it? any easy sample?

how do i go from Toolkit.getDefaultToolkit().getImage(“c://mypic.jpg”);

to simply using a png or tga?

The toolkit method WILL load a PNG as well.

Toolkit.getDefaultToolkit().getImage(“c:\mypic.PNG”); // this works for Java 1.3 and beyond

But using ImageIO is recommended for Java 5 and above. If you need loaders for more formats you can get them from the JAI Tools download - it has ImageIO loaders for a few more formats.

ImageIO is easy to use:

Image img = ImageIO.read(“c:\mypic.PNG”);

You only need to mess around with ImageReaders and that stuff when you really need to control more about the process.

BufferedImage foo;
[…]
try{
foo=ImageIO.read(new BufferedInputStream(getClass().getResourceAsStream("/images/foo.png")));
}catch(IOException e){
e.printStackTrace();
}

ImageIO cant read TGAs right now (out of the box… there is a tga reader for it from realityinteractive).

You can find a simple demo application (source included) here:
http://kaioa.com/k/jarimage.jar

“c://mypic.jpg” is really really bad btw :slight_smile:

edit: Oh and one advantage of ImageIO is that it loads synchronously. That means that the image is fully loaded after the method returned. So, you dont need to fiddle around with MediaTracker or anything like that.

Relax Onyx. I use relatice paths for my software not the c://whatever.jpg i showed as example ;D