From 5944ddf2551fcc9a20564e96ddb2ef83efb9e487 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 25 May 2009 11:12:38 +0000 Subject: [PATCH] From Wojciech Lewandowski, "Two fixes for LUMINANCE and ALPHA_LUMINACE pixel formats written into DDS file. Component masks were incorrect. I tested results with ultimate DDS compatibitlity tester ie Microsoft DirectX Texture tool ;-). I have also added comment with warning about possible problems when writing other than 8 bit component pixel formats. " --- src/osgPlugins/dds/ReaderWriterDDS.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/osgPlugins/dds/ReaderWriterDDS.cpp b/src/osgPlugins/dds/ReaderWriterDDS.cpp index 85355b42c..24365cdbc 100644 --- a/src/osgPlugins/dds/ReaderWriterDDS.cpp +++ b/src/osgPlugins/dds/ReaderWriterDDS.cpp @@ -9,11 +9,19 @@ * ARB_texture_compression.pdf * Author: Sebastien Domine, NVIDIA Corporation * -* CREATED BY: Rune Schmidt Jensen, rsj@uni-dk +* CREATED BY: Rune Schmidt Jensen, rsj@uni-dk * * HISTORY: Created 31.03.2003 * Modified 13.05.2004 * by George Tarantilis, gtaranti@nps.navy.mil +* Modified 22.05.2009 +* Wojtek Lewandowski, lewandowski@ai.com.pl +* +* WARNING: +* Bit Masks in the WrtiteDDS are set for 8 bit components +* write with 4 or 16 bit components will +* probably produce corrupted file +* Wojtek Lewandowski 2009-05-22 * **********************************************************************/ @@ -716,10 +724,6 @@ printf("CORRECTO**> gtsibim:%d grsib:%d mi_size:%d lPitch%d\n", */ - - - - bool WriteDDSFile(const osg::Image *img, std::ostream& fout) { @@ -793,8 +797,8 @@ bool WriteDDSFile(const osg::Image *img, std::ostream& fout) break; case GL_LUMINANCE_ALPHA: { - ddpf.dwRBitMask = 0x00ff0000; - ddpf.dwRGBAlphaBitMask = 0x000000ff; + ddpf.dwRBitMask = 0x000000ff; + ddpf.dwRGBAlphaBitMask = 0x0000ff00; PF_flags |= (DDPF_ALPHAPIXELS | DDPF_LUMINANCE); ddpf.dwRGBBitCount = pixelSize; ddsd.lPitch = img->getRowSizeInBytes(); @@ -814,7 +818,7 @@ bool WriteDDSFile(const osg::Image *img, std::ostream& fout) break; case GL_LUMINANCE: { - ddpf.dwRBitMask = 0x00ff0000; + ddpf.dwRBitMask = 0x000000ff; PF_flags |= DDPF_LUMINANCE; ddpf.dwRGBBitCount = pixelSize; ddsd.lPitch = img->getRowSizeInBytes();