Archived

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

Ut

2D File formats

Recommended Posts

I''m going to write an image reader, and I wanted to hear opinions on what might be a good choice. I''ve written a RAW bitmap reader before, but I want something a little more practical, so I''m thinking either Windows Bitmap, but this is still not practical since Bitmaps take up so much space. So I''m thinking JPEG. Is there any reason I shouldn''t write a JPEG reader? Is there some fundamental flaw with it that makes it impractical for game development. I noticed that most games seem to have their own, or at least they read in some other format and convert it to their own. Is this only to stop malicious users from wrecking textures and such? I''m just writing this as a small module for a larger project, so if someone knows of source available that already does this, I''d be glad to hear about it. Ut

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The only problem with jpeg is that there is no alpha channel (what I consider as a major design flaw).

Most games use proprietary formats to store more game specific data along with the texture, such as multiple mipmap levels, LOD detail data, etc...

Share this post


Link to post
Share on other sites
No reason to reinvent the wheel (unless you want to as a learning exercise). If you use directx, it has functions (D3DXLoadSurfaceFromFile, D3DXCreateTextureFromFile) for you already to load jpg, tga, bmp, and png and convert to the proper format. If not, you can get source for png from www.libpng.org. PNG files support alpha plus losses compression, so they are usually a better choice than jpg, unless you really need a small file and can put up with the lossy compression and lack of aplha in jpg.

Share this post


Link to post
Share on other sites
I might look into PNG. I stumbled upon that D3DXCreateTextureFromFile last night looking through the D3D8 documentation, but I''ll be using OpenGL and to my knowledge there''s no similiar function.

Thanks for the advice!

Ut

Share this post


Link to post
Share on other sites