Commit 146e8ba6c591c961864fedfa7cec5de6286857fe

henry 2001-08-27T03:11:27

Static cast float to unsigned char in bitmap code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/src/FTPixmapGlyph.cpp b/src/FTPixmapGlyph.cpp
index a54591c..87b9750 100755
--- a/src/FTPixmapGlyph.cpp
+++ b/src/FTPixmapGlyph.cpp
@@ -50,10 +50,10 @@ FTPixmapGlyph::FTPixmapGlyph( FT_Glyph glyph, const unsigned int gi)
     	--destHeight;
     	for(int x = 0; x < srcWidth; ++x)
     	{
-			*( data + ( destHeight * destWidth  + x) * 4 + 0) = ftglColour[0] * 255.0f;
-			*( data + ( destHeight * destWidth  + x) * 4 + 1) = ftglColour[1] * 255.0f;
-			*( data + ( destHeight * destWidth  + x) * 4 + 2) = ftglColour[2] * 255.0f;
-			*( data + ( destHeight * destWidth  + x) * 4 + 3) = ftglColour[3] * (*( source->buffer + ( y * srcPitch) + x));
+			*( data + ( destHeight * destWidth  + x) * 4 + 0) = static_cast<unsigned char>( ftglColour[0] * 255.0f);
+			*( data + ( destHeight * destWidth  + x) * 4 + 1) = static_cast<unsigned char>( ftglColour[1] * 255.0f);
+			*( data + ( destHeight * destWidth  + x) * 4 + 2) = static_cast<unsigned char>( ftglColour[2] * 255.0f);
+			*( data + ( destHeight * destWidth  + x) * 4 + 3) = static_cast<unsigned char>( ftglColour[3] * (*( source->buffer + ( y * srcPitch) + x)));
     	}    	
     }