diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-12-12 00:41:28 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-12-12 00:41:28 +0300 |
commit | a6e169e2d7259745203d20c5124d3ab911e60e63 (patch) | |
tree | 74a6fedd11696326b68e7e2eb99b237632510bae | |
parent | 944997f33d5d743929fba700fe1d7515fcd960fa (diff) | |
download | evol-tools-a6e169e2d7259745203d20c5124d3ab911e60e63.tar.gz evol-tools-a6e169e2d7259745203d20c5124d3ab911e60e63.tar.bz2 evol-tools-a6e169e2d7259745203d20c5124d3ab911e60e63.tar.xz evol-tools-a6e169e2d7259745203d20c5124d3ab911e60e63.zip |
Add debug info to dyecmd.
-rwxr-xr-x | dyecmd/src/dye.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/dyecmd/src/dye.cpp b/dyecmd/src/dye.cpp index 77da2eb..323c173 100755 --- a/dyecmd/src/dye.cpp +++ b/dyecmd/src/dye.cpp @@ -22,6 +22,7 @@ #include <algorithm> #include <sstream> #include <iostream> +#include <stdio.h> #include "dye.h" @@ -80,29 +81,45 @@ Palette::Palette(const std::string &description) void Palette::getColor(int intensity, int color[3]) const { + printf ("---------------------------------------------\n"); + printf ("intensity=%d\n", intensity); + printf ("image color: %d, %d, %d\n", color[0], color[1], color[2]); + // Return implicit black if (intensity == 0) { color[0] = 0; color[1] = 0; color[2] = 0; + printf ("set color to zero\n"); return; } int last = mColors.size(); - if (last == 0) return; + printf ("last=%d\n", last); + if (last == 0) + return; int i = intensity * last / 255; int t = intensity * last % 255; + printf ("i = intensity * last / 255 = %d\n", i); + printf ("t = intensity * last %% 255 = %d\n", t); + int j = t != 0 ? i : i - 1; + printf ("j = t != 0 ? i : i - 1 = %d\n", j); // Get the exact color if any, the next color otherwise. int r2 = mColors[j].value[0], g2 = mColors[j].value[1], b2 = mColors[j].value[2]; + printf ("r2 = mColors[j].value[0]=%d\n", r2); + printf ("g2 = mColors[j].value[1]=%d\n", g2); + printf ("b2 = mColors[j].value[2]=%d\n", b2); + if (t == 0) { + printf ("t == 0, return rgb = %d, %d, %d\n", r2, g2,b2); // Exact color. color[0] = r2; color[1] = g2; @@ -112,17 +129,25 @@ void Palette::getColor(int intensity, int color[3]) const // Get the previous color. First color is implicitly black. int r1 = 0, g1 = 0, b1 = 0; + printf ("r1=g1=b1=0\n"); if (i > 0) { r1 = mColors[i - 1].value[0]; g1 = mColors[i - 1].value[1]; b1 = mColors[i - 1].value[2]; + printf ("r1 = mColors[i - 1].value[0] = %d\n", r1); + printf ("g1 = mColors[i - 1].value[1] = %d\n", g1); + printf ("b1 = mColors[i - 1].value[2] = %d\n", b1); } // Perform a linear interpolation. color[0] = ((255 - t) * r1 + t * r2) / 255; color[1] = ((255 - t) * g1 + t * g2) / 255; color[2] = ((255 - t) * b1 + t * b2) / 255; + printf ("result color:\n"); + printf ("color[0] = ((255 - t) * r1 + t * r2) / 255 = %d\n", color[0]); + printf ("color[1] = ((255 - t) * g1 + t * g2) / 255 = %d\n", color[1]); + printf ("color[2] = ((255 - t) * b1 + t * b2) / 255 = %d\n", color[2]); } Dye::Dye(const std::string &description) |