Jump to content
  • Advertisement
Sign in to follow this  
mrbaggins

[SDL] Isometric tiles: Which image format?

This topic is 2901 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

Just wondering before I start this project... with SDL, am I better of blitting bmp's and a mask to the screen, BMP's with a keycolour, or just use transparent PNG's and let it work it out?

Or another option?

And then with other things (objects on the world), same question. Would think you'd do everything the same right through?

Share this post


Link to post
Share on other sites
Advertisement
Using a mask or colour key will only give you binary transparency. That is a pixel can be either transparent, or not. Using a format such as transparent PNG's will let you have a lot more control over the transparency, letting you use antialiased images and such, because you can have 255 different levels of transparency (assuming the alpha channel is 1 byte).

Another consideration is compression. BMP's are uncompressed (they might have RLE encoding, I'm not sure), whereas PNG files support lossless DEFLATE compression. Therefore, using PNG files will give you drastically smaller file sizes than using BMP files, which can be important, especially if delivering your game/app over the internet.

Oh, you might also be wondering about the rendering speed difference between the formats. I haven't done (or seen) any tests using SDL, but I would imaging alpha transparency would slow down rendering slightly, but I doubt it would have enough impact to make your game/app run slowly.

So really, considering the file size benefits and the better transparency there's no real reason not to use PNG's!

Share this post


Link to post
Share on other sites
Note: Assuming SDL 1.2 without 3d acceleration

Quote:
Oh, you might also be wondering about the rendering speed difference between the formats. I haven't done (or seen) any tests using SDL, but I would imaging alpha transparency would slow down rendering slightly, but I doubt it would have enough impact to make your game/app run slowly.

I have done tests and color keying is much faster than alpha blending when using SDL_BlitSurface. You will see a distinct performance drop as you use more alpha blending - the point at which this becomes an issue for your game however is dependent on the volume of pixels SDL must blend. A moderate amount may be acceptable depending on the type of game. From personal experience most 2d games can get by using color keys for characters and tiles while using a small amount of alpha blending for effects.

Quote:
Another consideration is compression. BMP's are uncompressed (they might have RLE encoding, I'm not sure), whereas PNG files support lossless DEFLATE compression. Therefore, using PNG files will give you drastically smaller file sizes than using BMP files, which can be important, especially if delivering your game/app over the internet.

The file size only saves you disk size, not RAM. SDL_Surfaces are uncompressed bitmaps in memory regardless of the image type on disk. On a side not you also need a third party library such as SDL_Image or SOIL etc. to load anything other than a bitmap in SDL.

Quote:
Just wondering before I start this project... with SDL, am I better of blitting bmp's and a mask to the screen, BMP's with a keycolour, or just use transparent PNG's and let it work it out?

With SDL masking is not necessary and in fact is more overhead than color keying. With color keying you never process the pixel that matches the color key - once it matches the key you move on to the next pixel.

Alpha blending requires some calculation on both the source and destination colors even for transparent pixels which although optimized is still more overhead than color keys.

In the end if you really want to use alpha heavily (which comes with it's own blending issues) do it with a 3d API like OpenGL or Direct3D where it gets done on the graphics hardware for free.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!