[osg-users] DDS Writer - Format Bug

David Spilling david.spilling at gmail.com
Thu Sep 6 09:50:20 PDT 2007

Dear All,

Does anybody use the DDS plugin to read and write DDS files? I am a bit
confused with regards to RGB vs. BGR; even looking at the DDS plugin code,
I'm still not sure:

1) Does the DDS file format _demand_ that the byte order is BGRA? As far as
I can tell, it doesn't, because you specify the byte masks for R,G,B,A

2) If given a source image with GL_RGBA, does the DDS writer swap R and B to
write BGRA? As far as I can tell,it doesn't, because the actual "write" call
in line 894 (of ReaderWriterDDS.cpp) just dumps the image->data to file in

3) In terms of byte mask order, the _reader_ looks right to me : line 346
has :
            { "A8B8G8R8",    32, 0x000000ff, 0x0000ff00, 0x00ff0000,
where the bytemasks are R,G,B,A in order.

However the writer for the equivalent format, GL_RGBA, has the byte masks
(R,G,B,A) as
           {0x00ff0000; 0x0000ff00; 0x000000ff; 0xff000000}
which would seem to be B,G,R,A.

4) If I create a blank red image and save it to disk, then examine the image
with 3rd party image viewing tools, going via the png format (for example)
gives me a red image, but going via the dds format gives me a blue image.

5) Lastly, as an aside, do any of the other OSG image plugins write 3d (i.e.
r>1) images?

I didn't want to just to go ahead and submit a fix, because I'm not familiar
with the DDS format. The latest submission on it was from the 10th June, so
it is moderately active. Can anybody let me know whether the described
behaviour and code is intentional, i.e. not a bug? If it is a bug, I'll
submit a fix.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070906/ae294feb/attachment-0002.htm>

More information about the osg-users mailing list