Archived

This topic is now archived and is closed to further replies.

Tai-Pan

PCX Vs BMPs

Recommended Posts

Im writing a little game, and im wondering what should I use for my backgrounds and sprites?? First I thought that using pcx would be the best idea, because they are small; but then I heard that bmps load faster than the other formats..or something like that. What should I use? I dont care too much about memory, cos im not having many many sprites, but i really need some speed.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You should use JPEG (*.jpg) and TARGA (*.tga)
image formats. JPEG use the best compression and TGA gives you alpha channel.

Try the Independent JPEG Group''s software, its shareware.

http://www.ijg.org/

Share this post


Link to post
Share on other sites
Targa''s are the easiest to load, they also have an alpha channel. I actually quite like pcx files, although they only support 24bit. The file format description at www.wotsit.org also has some sample code for expanding and compressing the files.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
With the IJG (Independent JPEG group) library, you can load and save all of these file formats:

JPEG
BMP /* BMP image file format */
GIF /* GIF image file format */
PPM /* PBMPLUS PPM/PGM image file format */
TARGA /* Targa image file format */

Cheers!

Share this post


Link to post
Share on other sites
quote:
Original post by Tai-Pan
thanks people..but sorry..I forgot to tell you that Im using SDL..so I cant use JPEGs..I rather stick with bmps or PCXs..what do you recommend?


Either will load fast enough, even TGAs with an extra byte for the alpha. Doing a plain C byte reading, you should be able to load a 512x512 TGAs in less than 20ms. My suggestion, don''t worry about loading speed.

Anyway, for sprites, if they aren''t bigger than 256x256 and won''t have too much color differences, go to 8bits PCXs. They''re easy to read and are compact.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

As MatuX here stays, you should not worry to much about loadspeed when you dont have to much graphics. It want be of any significance to you.

JPG is not a good choice for graphics to games. Yes, it can compress files very good but this is on lack of quality. The more you compress a JPG file the more you loose its quality. Therefore JPG is best suited for photographs with 16 mills of colors where you cant see so easily the change of quality. If you want to keep the quality "as is", then you cannot compress the JPG file and the you still have the size.

The main difference between the PCX and BMP (except for headers and such) is that PCX files uses a kind of a compression (called runlength compression if I dont remember wrong) and can therefore make smaller files than BMP. The size only becomes significantly smaller if the graphics contain the same repeated color on a line of pixels and for bigger files. BMP does not use compression.

They are both very easy to load, however, I would recommend BMP since the Windows API already have functions for reading BMP files which in my opinion makes BMP easier to load. Though the difference is quite small.

Also, if you want to use pixelformat with more than 8 bits pr. color (i.e. 15, 16, 24 bits etc), Windows will automatically convert the file loaded through its API functions for you to the right pixel format.

With 8 bits per pixel or less, both are very much the same except the size, which will in general only be significant the bigger the size of the file is (i.e. height and width of the picture), and that I still mean that using the API to load the file instead of making your own loader is easier.

- Calvin

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
(Also, if you want to use pixelformat with more than 8 bits pr. color (i.e. 15, 16, 24 bits etc), Windows will automatically convert the file loaded through its API functions for you to the right pixel format.)

^^^^^^^^
Sorry, forgot to add that this is after a bitblt of course.

- Calvin

Share this post


Link to post
Share on other sites
quote:
Original post by Tai-Pan
thanks people..but sorry..I forgot to tell you that Im using SDL..so I cant use JPEGs..I rather stick with bmps or PCXs..what do you recommend?

You know you can use the SDL_Image library to load most other formats?



[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files ]

Share this post


Link to post
Share on other sites