Sign in to follow this  

2D game graphics : which useful file format ?

This topic is 3862 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i'm developing a 2D game with DirectX 9 & VC++. I'm a beginner in this area, and i was trying to figure out which graphic file format my program will have to load & use. I'd like to use the JPG format, but i'm not sure it is a free-of-charge file format; moreover, if i compress a picture which includes empty areas (to be handled via color-keying), compression artifacts may happen, making a plain colour area filled with color variations, which will be not rejected from color-keying (no transparent area, but a messy coloured area in the final sprite rendering). So, i was thinking about PNG, but compression is very littler (about half than JPG). The question is : do you know which is the standard graphic file format used to include 2d graphics into a game ? Consider i would like to distribute the game via Internet, so i can't rely on installation files consisting of hundreds of megabytes of size...

Share this post


Link to post
Share on other sites
I'm no expert on image file formats but from what I understand if you're going to be using pixel art you're far better of with png than jpg. The reason being that in this style of art every pixel counts and the sprites are usualy created with limited colour palletes. Png will give you an exact copy of your art where as jpg's compression can change your colours and introduce artifacts which detracts from the crispness of your art. As well as this png allows for transparency and partial transparencies which will be vital for 2d sprites.

Share this post


Link to post
Share on other sites
Just pick a non-lossy format such as PNG, TGA, PCX, RLE, etc. There are free libs for just about every format under the sun, and windows itself supports many formats.

If, for some reason, you want to avoid external libraries the PCX and RLE formats are fairly trivial to write loaders for. PNG/TGA are more complicated due to the compression scheme, so you'd be better off using a library most likely. Of course, PNG/TGA compress more nicely than PCX/RLE though.


Also, if it suits your graphics, even an 8-bit bitmap will do fine with an optimized palette. If you use a limited amount of colors per graphic (ideally, less than or equal to 256 colors) there will be no loss of quality, and the fill will be 1/4 the size of a 32-bit bitmap.

Share this post


Link to post
Share on other sites
As an additional thought in support of PNG:

Both PNG and JPEG support scaling levels of compression; the primary difference being that higher JPEG compression degrades your image in a major way. The highest level PNG compression just takes longer to load, but is still really effective.

Share this post


Link to post
Share on other sites
Definitely PNG or TGA. PNG has the added benefit of being a standard internet file format too, which may or may not be useful.

Share this post


Link to post
Share on other sites
I'm a PNG fan, too. Though I should mention that my game supports many, many different image types thanks to SDL_image which lets me load any image type with one function call.

Share this post


Link to post
Share on other sites

This topic is 3862 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this