mail[Wesnoth-commits] r20129 - /trunk/src/sdl_utils.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by koraq on September 05, 2007 - 19:02:
Author: mordante
Date: Wed Sep  5 19:01:50 2007
New Revision: 20129

URL: http://svn.gna.org/viewcvs/wesnoth?rev=20129&view=rev
Log:
C-style cast cleanup. 

Modified:
    trunk/src/sdl_utils.cpp

Modified: trunk/src/sdl_utils.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/sdl_utils.cpp?rev=20129&r1=20128&r2=20129&view=diff
==============================================================================
--- trunk/src/sdl_utils.cpp (original)
+++ trunk/src/sdl_utils.cpp Wed Sep  5 19:01:50 2007
@@ -435,9 +435,10 @@
                        // Ok, this is no big deal :)
                        // The correct formula being:
                        // gray=0.299red+0.587green+0.114blue
-                       const Uint8 avg = (Uint8)((77*(Uint16)red +
-                                                  150*(Uint16)green +
-                                                  29*(Uint16)blue) / 256);
+                       const Uint8 avg = static_cast<Uint8>((
+                               77 * static_cast<Uint16>(red) +
+                               150 * static_cast<Uint16>(green) +
+                               29 * static_cast<Uint16>(blue)) / 256);
 
 
                        *beg = SDL_MapRGBA(nsurf->format,avg,avg,avg,alpha);
@@ -475,13 +476,14 @@
                        // Ok, this is no big deal :)
                        // The correct formula being:
                        // gray=0.299red+0.587green+0.114blue
-                       const Uint8 avg = (Uint8)((77*(Uint16)red +
-                                                  150*(Uint16)green +
-                                                  29*(Uint16)blue) / 256);
+                       const Uint8 avg = static_cast<Uint8>((
+                               77 * static_cast<Uint16>(red) +
+                               150 * static_cast<Uint16>(green) +
+                               29 * static_cast<Uint16>(blue)) / 256);
                        // then tint 77%, 67%, 72%
-                       const Uint8 r=(Uint8)((avg*196)>>8);
-                       const Uint8 g=(Uint8)((avg*171)>>8);
-                       const Uint8 b=(Uint8)((avg*184)>>8);
+                       const Uint8 r= ((avg * 196) >> 8);
+                       const Uint8 g= ((avg * 171) >> 8);
+                       const Uint8 b= ((avg * 184) >> 8);
 
 
                        *beg = SDL_MapRGBA(nsurf->format,r,g,b,alpha);




Related Messages


Powered by MHonArc, Updated Wed Sep 05 19:20:19 2007