# What is the best image format for textures?

**URL:** <https://community.khronos.org/t/what-is-the-best-image-format-for-textures/35884>\
**Category:** OpenGL: Advanced Coding\
**Created:** [November 26, 2002, 10:15am UTC](https://community.khronos.org/t/what-is-the-best-image-format-for-textures/35884 "2002-11-26T10:15:00Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucidmm](https://community.khronos.org/letter_avatar_proxy/v4/letter/l/e5b9ba/32.png) [@lucidmm](https://community.khronos.org/u/lucidmm)\
**Post date:** [November 26, 2002, 10:15am UTC](https://community.khronos.org/t/what-is-the-best-image-format-for-textures/35884/1 "2002-11-26T10:15:00Z")

</div>

Are there any good references for image formats?

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![Nutty](https://community.khronos.org/letter_avatar_proxy/v4/letter/n/a3d4f5/32.png) [@Nutty](https://community.khronos.org/u/Nutty)\
**Post date:** [November 26, 2002, 11:07am UTC](https://community.khronos.org/t/what-is-the-best-image-format-for-textures/35884/2 "2002-11-26T11:07:00Z")

</div>

If you’re not bothered about space use .TGA’s

. They’re lossless. So ideal for storing normal maps.  
. They support alpha channels.  
. They’re bloody easy to decode. I have some code on my site in some of my demos that will do it. non-compressed and RLE, 24 and 32bit.  
[http://opengl.nutty.org/](http://opengl.nutty.org/)

Else try Jpegs, but not for normal maps, cos the artifacting makes normal maps look crap.

You could try PNG, but not all PNG supporting programs support PNG alpha. i.e. Photoshop 6. They’re also lossless.

Nutty

---

<div class="post-metadata">

**Author:** ![jra101](https://community.khronos.org/letter_avatar_proxy/v4/letter/j/8edcca/32.png) [@jra101](https://community.khronos.org/u/jra101)\
**Post date:** [November 26, 2002, 11:11am UTC](https://community.khronos.org/t/what-is-the-best-image-format-for-textures/35884/3 "2002-11-26T11:11:00Z")

</div>

Try the DDS format. It can store 1D, 2D, 3D, and cubemap textures, with their mipmaps, in a single file.

Another nice feature is support for the DXTC compression format which is supported natively by the hardware so you won’t need to be uncompress it before sending it to the video card.

---

<div class="post-metadata">

**Author:** ![system](https://community.khronos.org/uploads/default/original/2X/b/ba89cb49313a0e869198c8be354afde8bcae027e.png) [@system](https://community.khronos.org/u/system)\
**Post date:** [November 26, 2002, 11:41am UTC](https://community.khronos.org/t/what-is-the-best-image-format-for-textures/35884/4 "2002-11-26T11:41:00Z")

</div>

Are there libraries out there that support DDS?

NOt including the Direct utility package.

V-man

---

<div class="post-metadata">

**Author:** ![jra101](https://community.khronos.org/letter_avatar_proxy/v4/letter/j/8edcca/32.png) [@jra101](https://community.khronos.org/u/jra101)\
**Post date:** [November 26, 2002, 11:43am UTC](https://community.khronos.org/t/what-is-the-best-image-format-for-textures/35884/5 "2002-11-26T11:43:00Z")

</div>

Try the DDS loader I wrote:  
[http://cvs1.nvidia.com/OpenGL/include/shared/nv\_dds.h](http://cvs1.nvidia.com/OpenGL/include/shared/nv_dds.h)  
[http://cvs1.nvidia.com/OpenGL/src/shared/nv\_dds.cpp](http://cvs1.nvidia.com/OpenGL/src/shared/nv_dds.cpp)

[This message has been edited by jra101 (edited 11-26-2002).]

---

<div class="post-metadata">

**Author:** ![Humus](https://community.khronos.org/user_avatar/community.khronos.org/humus/32/47_2.png) [@Humus](https://community.khronos.org/u/Humus)\
**Post date:** [November 26, 2002, 2:58pm UTC](https://community.khronos.org/t/what-is-the-best-image-format-for-textures/35884/6 "2002-11-26T14:58:00Z")

</div>

… or grab the Image.cpp file from my framework at [http://humus2.campus.luth.se/~humus/](http://humus2.campus.luth.se/~humus/)

---

<div class="post-metadata">

**Author:** ![imported\_jwatte](https://community.khronos.org/letter_avatar_proxy/v4/letter/i/bbce88/32.png) [@imported\_jwatte](https://community.khronos.org/u/imported_jwatte)\
**Post date:** [November 26, 2002, 8:02pm UTC](https://community.khronos.org/t/what-is-the-best-image-format-for-textures/35884/7 "2002-11-26T20:02:00Z")

</div>

DDS is the preferred vehicle for textures compressed using S3TC (DXTn). Using this compression will give you a 4x texture fetch rate boost compared to 16-bit textures, at an often acceptable quality loss. DDS files can also store MIP maps pre-calculated, which saves a little CPU when loading (and, if they’re compressed, it’s almost impossible to generate good MIP maps at load time).

nVIDIA has a Photoshop DDS plugin on their web site, as well as a Max ditto.

To load a DDS, you read the first 512 (or 128? I forget) bytes into a DDSURFACEDESC2 (minus a few header bytes), assert that the compression format is what you expect, get the width/height from the header, and then read the appropriate amount of data from the file after the header. (bytecount = width\*height/2) MIP maps are just stored consecutively after that.

Last, both DXTC and DDSURFACEDESC2 and the DDS file format are documented on MSDN and/or in the DirectX 8 SDK, all of which are freely available on Microsoft’s web site.

---

<div class="post-metadata">

**Author:** ![Diapolo](https://community.khronos.org/letter_avatar_proxy/v4/letter/d/bbe5ce/32.png) [@Diapolo](https://community.khronos.org/u/Diapolo)\
**Post date:** [November 27, 2002, 2:13am UTC](https://community.khronos.org/t/what-is-the-best-image-format-for-textures/35884/8 "2002-11-27T02:13:00Z")

</div>

I´m using the DDS format, too (currently my loading function only supports DXT1, DXT3 and DXT5 compressed textures with or without mipmaps).  
I really like it ![](http://www.opengl.org/discussion_boards/ubb/smile.gif).

For Normalmaps I use the RAW-Image format.  
It has got not header, only the data, but it´s pretty easy to handle, but only Paint Shop Pro seems to support that format to my knowledge …

Diapolo

---

<div class="post-metadata">

**Author:** ![Julien\_Cayzac](https://community.khronos.org/user_avatar/community.khronos.org/julien_cayzac/32/1742_2.png) [@Julien\_Cayzac](https://community.khronos.org/u/Julien_Cayzac)\
**Post date:** [November 27, 2002, 2:19am UTC](https://community.khronos.org/t/what-is-the-best-image-format-for-textures/35884/9 "2002-11-27T02:19:00Z")

</div>

PNG support an arbitrary number of layers, so it can store Cube Maps as well (using 6 layers).  
The format also support (though libpng is a bit buggy here) arbitrary channels’ depth so it fits perfectly 32-bit channel needs for ng cards…

Julien.

---

<div class="post-metadata">

**Author:** ![gibber](https://community.khronos.org/letter_avatar_proxy/v4/letter/g/f6c823/32.png) [@gibber](https://community.khronos.org/u/gibber)\
**Post date:** [November 27, 2002, 6:25am UTC](https://community.khronos.org/t/what-is-the-best-image-format-for-textures/35884/10 "2002-11-27T06:25:00Z")

</div>

V-Man: wrote

> Are there libraries out there that support DDS?

DevIL supports DDS loading.

[http://openil.sourceforge.net/](http://openil.sourceforge.net/)

---

<div class="post-metadata">

**Author:** ![dorbie](https://community.khronos.org/user_avatar/community.khronos.org/dorbie/32/53_2.png) [@dorbie](https://community.khronos.org/u/dorbie)\
**Post date:** [November 27, 2002, 9:16am UTC](https://community.khronos.org/t/what-is-the-best-image-format-for-textures/35884/11 "2002-11-27T09:16:00Z")

</div>

…and they have a cool logo.

Definitely use a library for this. Nobody should be wasting time writing their own file loaders without good reason. I’d recommend PNG files personally, they include lossless compression, support alpha and luminance alpha formats, are supported in many packages and can be viewed casually in applications like web browsers and support gamma information making platform of creation a non issue. You can also get libpng straight from the horses mouth if you care.

---

<div class="post-metadata">

**Author:** ![ehart](https://community.khronos.org/letter_avatar_proxy/v4/letter/e/e36b37/32.png) [@ehart](https://community.khronos.org/u/ehart)\
**Post date:** [November 27, 2002, 11:12am UTC](https://community.khronos.org/t/what-is-the-best-image-format-for-textures/35884/12 "2002-11-27T11:12:00Z")

</div>

I like PNG’s, but I have really found a lot of nice features in TIFF’s. They offer a lot more flexibility then PNG’s and they can support deflate compression like PNG’s too.

The only problem is that most of the nice features aren’t supported in art programs. (32-bit float images, volume images, etc)

-Evan

---

<div class="post-metadata">

**Author:** ![Julien\_Cayzac](https://community.khronos.org/user_avatar/community.khronos.org/julien_cayzac/32/1742_2.png) [@Julien\_Cayzac](https://community.khronos.org/u/Julien_Cayzac)\
**Post date:** [November 27, 2002, 12:50pm UTC](https://community.khronos.org/t/what-is-the-best-image-format-for-textures/35884/13 "2002-11-27T12:50:00Z")

</div>

> Originally posted by ehart:  
> The only problem is that most of the nice features aren’t supported in art programs. (32-bit float images, volume images, etc)

FilmGimp is a 32-bit per channel enabled version of Gimp. Maybe it support 32-bit float TIFFs, I’m not sure.

Julien.

---

<div class="post-metadata">

**Author:** ![zed](https://community.khronos.org/user_avatar/community.khronos.org/zed/32/8_2.png) [@zed](https://community.khronos.org/u/zed)\
**Post date:** [November 27, 2002, 6:29pm UTC](https://community.khronos.org/t/what-is-the-best-image-format-for-textures/35884/14 "2002-11-27T18:29:00Z")

</div>

i made an greyscale image the other day where is each pixel is a difference from its neighbouring pixel (basically gives u high (difference) resolution with minimum memory)  
anyways has this been done before?  
ie did i waste my time writing the code when an already existing image format exists already ( ![](http://www.opengl.org/discussion_boards/ubb/smile.gif)) most likely of better quality.  
and if so whats the nme of this image format?  
ta

---

<div class="post-metadata">

**Author:** ![imported\_jwatte](https://community.khronos.org/letter_avatar_proxy/v4/letter/i/bbce88/32.png) [@imported\_jwatte](https://community.khronos.org/u/imported_jwatte)\
**Post date:** [November 28, 2002, 7:42am UTC](https://community.khronos.org/t/what-is-the-best-image-format-for-textures/35884/15 "2002-11-28T07:42:00Z")

</div>

PNG uses neighboring difference as one of the possible filters that you can use before actually compressing the image; this will lead to better compression ratio for certain classes of images.

The idea (coding deltas instead of absolutes) is fairly old (and it’s been used for audio, too) but I can’t think of any popular format that actually uses it as the main image coding format these days.

Oh, speaking about grayscale images: the .DDS plug-in for Photoshop (from nVIDIAs site) won’t let you save a grayscale image; it can only save various RGB images, plus paletted; and evenso, it doesn’t accept an indexed input image. I knew there was a reason for good-old TGA to stick around 🙂
