From 2d74de8a361d38982c5121354f6071df5ea3d78e Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 30 Mar 2015 12:04:35 +0200 Subject: [PATCH] Separate dither matrix per color channel --HG-- branch : develop --- code/nel/tools/3d/tga_2_dds/tga2dds.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/3d/tga_2_dds/tga2dds.cpp b/code/nel/tools/3d/tga_2_dds/tga2dds.cpp index 19fd70d32..34b47735f 100644 --- a/code/nel/tools/3d/tga_2_dds/tga2dds.cpp +++ b/code/nel/tools/3d/tga_2_dds/tga2dds.cpp @@ -359,13 +359,27 @@ void dividSize (CBitmap &bitmap) } } -const int bayerDiv8[4][4] = { +const int bayerDiv8R[4][4] = { + 7, 3, 6, 2, + 1, 5, 0, 4, + 6, 2, 7, 3, + 0, 4, 1, 5, +}; + +const int bayerDiv8G[4][4] = { 0, 4, 1, 5, 6, 2, 7, 3, 1, 5, 0, 4, 7, 3, 6, 2, }; +const int bayerDiv8B[4][4] = { + 5, 1, 4, 0, + 3, 7, 2, 6, + 4, 0, 5, 1, + 2, 6, 3, 7, +}; + // *************************************************************************** int main(int argc, char **argv) { @@ -618,9 +632,9 @@ int main(int argc, char **argv) for (uint32 i = 0; i < rgba.size(); i += 4) { NLMISC::CRGBA &c = reinterpret_cast(rgba[i]); - c.R = (uint8)std::min(255, (int)c.R + bayerDiv8[x % 4][y % 4]); - c.G = (uint8)std::min(255, (int)c.G + bayerDiv8[x % 4][y % 4]); - c.B = (uint8)std::min(255, (int)c.B + bayerDiv8[x % 4][y % 4]); + c.R = (uint8)std::min(255, (int)c.R + bayerDiv8R[x % 4][y % 4]); + c.G = (uint8)std::min(255, (int)c.G + bayerDiv8G[x % 4][y % 4]); + c.B = (uint8)std::min(255, (int)c.B + bayerDiv8B[x % 4][y % 4]); ++x; x %= w; if (x == 0)