diff --git a/Common/Context.h b/Common/Context.h
index 6011ad66d4884fe9af4c29238a80a120e948237b..9f8bb46c109659a13a8d5df25768bf495dcda90b 100644
--- a/Common/Context.h
+++ b/Common/Context.h
@@ -27,13 +27,13 @@
 // headers.
 
 #if defined(HAVE_BIG_ENDIAN)
-#  define PACK_COLOR(R,G,B,A)   ( (R)<<24 | (G)<<16 | (B)<<8 | (A) )
+#  define PACK_COLOR(R,G,B,A)   ( (unsigned int)((R)<<24 | (G)<<16 | (B)<<8 | (A)) )
 #  define UNPACK_RED(X)         ( ( (X) >> 24 ) & 0xff )
 #  define UNPACK_GREEN(X)       ( ( (X) >> 16 ) & 0xff )
 #  define UNPACK_BLUE(X)        ( ( (X) >> 8 ) & 0xff )
 #  define UNPACK_ALPHA(X)       ( (X) & 0xff )
 #else
-#  define PACK_COLOR(R,G,B,A)   ( (A)<<24 | (B)<<16 | (G)<<8 | (R) )
+#  define PACK_COLOR(R,G,B,A)   ( (unsigned int)((A)<<24 | (B)<<16 | (G)<<8 | (R)) )
 #  define UNPACK_RED(X)         ( (X) & 0xff )
 #  define UNPACK_GREEN(X)       ( ( (X) >> 8 ) & 0xff )
 #  define UNPACK_BLUE(X)        ( ( (X) >> 16 ) & 0xff )