2D File formats

Started by
3 comments, last by Ut 22 years, 5 months ago
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
Advertisement
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...

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.
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
Hi I would go with targa files (.tga) because of the alpha channel and also because its file format is much like that of a bitmap. Anyway good luck with what ever you choose.

This topic is closed to new replies.

Advertisement