From bd518b8de6702ab1e276f7513bea735cee9417ef Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Wed, 10 Sep 2008 15:07:20 +0000 Subject: This is patch: [#15135] imbuf DDS support: sync to nvidia texture tools revision 602 + fix for ATI2 compressed normal maps It just updates the dds stuff. Provided by Amorilia Kent --- source/blender/imbuf/intern/dds/ColorBlock.cpp | 37 +++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'source/blender/imbuf/intern/dds/ColorBlock.cpp') diff --git a/source/blender/imbuf/intern/dds/ColorBlock.cpp b/source/blender/imbuf/intern/dds/ColorBlock.cpp index d298e8b5ea8..043fba9d675 100644 --- a/source/blender/imbuf/intern/dds/ColorBlock.cpp +++ b/source/blender/imbuf/intern/dds/ColorBlock.cpp @@ -53,6 +53,14 @@ ColorBlock::ColorBlock() { } +/// Init the color block from an array of colors. +ColorBlock::ColorBlock(const uint * linearImage) +{ + for(uint i = 0; i < 16; i++) { + color(i) = Color32(linearImage[i]); + } +} + /// Init the color block with the contents of the given block. ColorBlock::ColorBlock(const ColorBlock & block) { @@ -125,9 +133,36 @@ void ColorBlock::splatY() /// Returns true if the block has a single color. bool ColorBlock::isSingleColor() const { + Color32 mask(0xFF, 0xFF, 0xFF, 0x00); + uint u = m_color[0].u & mask.u; + for(int i = 1; i < 16; i++) { - if (m_color[0] != m_color[i]) + if (u != (m_color[i].u & mask.u)) + { + return false; + } + } + + return true; +} + +/// Returns true if the block has a single color, ignoring transparent pixels. +bool ColorBlock::isSingleColorNoAlpha() const +{ + Color32 c; + int i; + for(i = 0; i < 16; i++) + { + if (m_color[i].a != 0) c = m_color[i]; + } + + Color32 mask(0xFF, 0xFF, 0xFF, 0x00); + uint u = c.u & mask.u; + + for(; i < 16; i++) + { + if (u != (m_color[i].u & mask.u)) { return false; } -- cgit v1.2.3