diff options
author | madmaxoft <github@xoft.cz> | 2013-08-30 23:32:27 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-08-30 23:32:27 +0200 |
commit | 79b79e5b77fbbd70dab6cb23592991726a8c6d80 (patch) | |
tree | 044595dc2e0f19e2b4b6f4a5134c8caf77fc1675 /Tools/AnvilStats/ImageComposingCallback.cpp | |
parent | Merge branch 'Projectiles' (diff) | |
download | cuberite-79b79e5b77fbbd70dab6cb23592991726a8c6d80.tar cuberite-79b79e5b77fbbd70dab6cb23592991726a8c6d80.tar.gz cuberite-79b79e5b77fbbd70dab6cb23592991726a8c6d80.tar.bz2 cuberite-79b79e5b77fbbd70dab6cb23592991726a8c6d80.tar.lz cuberite-79b79e5b77fbbd70dab6cb23592991726a8c6d80.tar.xz cuberite-79b79e5b77fbbd70dab6cb23592991726a8c6d80.tar.zst cuberite-79b79e5b77fbbd70dab6cb23592991726a8c6d80.zip |
Diffstat (limited to '')
-rw-r--r-- | Tools/AnvilStats/ImageComposingCallback.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/Tools/AnvilStats/ImageComposingCallback.cpp b/Tools/AnvilStats/ImageComposingCallback.cpp index 138821698..eb43ad49f 100644 --- a/Tools/AnvilStats/ImageComposingCallback.cpp +++ b/Tools/AnvilStats/ImageComposingCallback.cpp @@ -72,7 +72,7 @@ void cImageComposingCallback::OnRegionFinished(int a_RegionX, int a_RegionZ) AString cImageComposingCallback::GetFileName(int a_RegionX, int a_RegionZ) { - return Printf("%s.%d.%d", m_FileNamePrefix.c_str(), a_RegionX, a_RegionZ); + return Printf("%s.%d.%d.bmp", m_FileNamePrefix.c_str(), a_RegionX, a_RegionZ); } @@ -148,7 +148,7 @@ int cImageComposingCallback::GetPixel(int a_RelU, int a_RelV) void cImageComposingCallback::SetPixelURow(int a_RelUStart, int a_RelV, int a_CountU, int * a_Pixels) { - ASSERT((a_RelUStart >= 0) && (a_RelUStart + a_CountU < IMAGE_WIDTH)); + ASSERT((a_RelUStart >= 0) && (a_RelUStart + a_CountU <= IMAGE_WIDTH)); ASSERT((a_RelV >= 0) && (a_RelV < IMAGE_HEIGHT)); ASSERT(a_Pixels != NULL); @@ -163,6 +163,36 @@ void cImageComposingCallback::SetPixelURow(int a_RelUStart, int a_RelV, int a_Co +int cImageComposingCallback::ShadeColor(int a_Color, int a_Shade) +{ + if (a_Shade < 64) + { + return MixColor(0, a_Color, a_Shade * 4); + } + return MixColor(a_Color, 0xffffff, (a_Shade - 64) * 4); +} + + + + + +int cImageComposingCallback::MixColor(int a_Src, int a_Dest, int a_Amount) +{ + int r = a_Src & 0xff; + int g = (a_Src >> 8) & 0xff; + int b = (a_Src >> 16) & 0xff; + int rd = a_Dest & 0xff; + int gd = (a_Dest >> 8) & 0xff; + int bd = (a_Dest >> 16) & 0xff; + int nr = r + (rd - r) * a_Amount / 256; + int ng = g + (gd - g) * a_Amount / 256; + int nb = b + (bd - b) * a_Amount / 256; + return nr | (ng << 8) | (nb << 16); +} + + + + void cImageComposingCallback::SaveImage(const AString & a_FileName) { cFile f(a_FileName, cFile::fmWrite); |