summaryrefslogtreecommitdiffstats
path: root/Tools/AnvilStats/ImageComposingCallback.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/AnvilStats/ImageComposingCallback.cpp')
-rw-r--r--Tools/AnvilStats/ImageComposingCallback.cpp34
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);