[Mono-list] new color.cs for inclusion in CVS

Paolo Molaro lupus@ximian.com
Thu, 7 Mar 2002 10:20:26 +0100


On 03/06/02 Dennis Hayes wrote:
> 	public struct Color
> 	{ 
> 		// Private transparancy (A) and R,G,B fields.
> 		int a;
> 		int r;
> 		int g;
> 		int b;
> 		public static Color FromArgb (int r, int g, int b)
> 		{
> 			//TODO: Is 255 the correct value to return for A?
> 			Color color;
> 			color.a = 255;
> 			color.r = r;
> 			color.g = g;
> 			color.b = b;
> 			return color;
> 		}

Since the values for R, G and B are of type byte (check the return type
of the A, R, G and B properties), you should use bytes for storage, not
ints. This way the whole structure nicely fits in 4 bytes instead of the
current 16.

lupus

-- 
-----------------------------------------------------------------
lupus@debian.org                                     debian/rules
lupus@ximian.com                             Monkeys do it better