Two Image Questions

Wow, a Java game programming forum. Glad I finally foudn this place!

It hit me mid-way through planning a new project (new graphics and interface for a fantasy strategy game originally played with circles and squares, very “Rogue”, I know) that I know… nothing about images for programming. Well, that didn’t come out right. I know well enough to say that BufferedImages don’t like me (I tried for a few weeks, once) and so forth, what I don’t know is something I know quite well for web design: which image format to use. I need a format that supports transparency and is still small in size. I’m not sure if I want to use gif or png or something else because my knowledge is strictly limited to web design - I don’t know if there’s anything better, or if one of those two works better with Java, or what have you.

My question for images is a lot more complicated, as it’s the challenge I put into the design to improve my skills. I want to create “contact sprites”, namely for showing damage being taken. Every weapon in the game is its own sprite, so that they can be interchanged. The trouble is, I can’t even begin to work out how to do the contact without spending way too much time duplicating images (one sprite of a spear attacking a peasent, another of a sword attacking a wolf, another of this attacking that… etc). Any ideas?

I generally use PNGs these days. If you need something that is very small and dont mind lossiness then JPEG would be a good solution.

What about a generic blood splat? Do it right and the splat can even hide the actual contact point so you dont need to really have pixel to pixel contact.

PNG: If you need to create translucent/transparent images (are little bit bigger in size than JPG/GIF)
JPG: for photo-style images with lots of colors where exact pixel colors do not matter (no transparency)
GIF: for basic transparent (not translucent) images. Good in compression if not so many pixels.

Yeah I use PNGs also. I noticed that fancy glow and transparency (at the same time) can’t be achieved with GIF… can someone explain to me (in addition to anwsering Black Drazon’s first post) what is translucet? Oh nvm I’ll google it first.

translucent: allows you to define a see-through level.

gif: either opaque or transparent only
png: from see-through level 0 (opaque) to level 255 (transparent).

Okay, so images in programming are like images on the web, except we know how TIFFs do special things for us, and they can’t ::). lol, well… TIFFs are messy anyways.

I think I can probably use the blood spatter! Or maybe something else that just occured to me… either way, thanks all!!

If I remember my Final Fantasy, I’m pretty sure it was always a general ‘hurt’ animation and an ‘attack’ animation…

[quote]PNG: If you need to create translucent/transparent images (are little bit bigger in size than JPG/GIF)
[/quote]
That’s funny, I find that png’s generally take less space. Actually just about the same amount. They are very similar formats, except png does not support animation (which is generally useless to us) whereas it does supports translucency (i.e. partial transparency for those it may concern). Oh, and .gif is a non-free format so just use .png (or JPG where appropriate).

[quote]That’s funny, I find that png’s generally take less space. Actually just about the same amount
[/quote]
I thought so too, but it always come out as slightly more than GIFs or JPG. At least for me. Do I do somthing wrong?

I don’t see any compression options for PNG? I use Photoshop.

I apologize to author for using his topic :slight_smile:
Mine come out slightley bigger also, but we’re talking about pics, they are to small to take any serious space even in raw, uncompressed format. It matters only if you need them downloaded from net every time you run an app. I remember somebody saying that pictures uncompress in memory anyway so it’s only their size in pixels that counts, with formula width * height * 3. Can anybody tell me why 3 at the end?

Size in memory (uncompressed): width * height * 3 [bytes]
3 bytes for: TYPE_RGB (Red, Green, Blue - each 1 byte)
4 bytes for: TYPE_ARGB where A is the alpha (tranlucency) value

I have just made a few tests. Using the ImageMagick convert function without arguments, .png files do indeed take considerably more space than .gifs. However, using Gimp I can specify a level of png compression, which at the highest level yields smaller file sizes than gif counterparts.