pro_cessor

RGB Extension Method

Mar 18th, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. internal static class HexToColorExtension
  2. {
  3.     public static Color Rgb(this int hex)
  4.     {
  5.         return Color.FromRgb((byte)(hex >> 16), (byte)(hex >> 8), (byte)(hex >> 0));
  6.     }
  7.  
  8.     public static Color Argb(this uint hex)
  9.     {
  10.         return Color.FromArgb((byte)(hex >> 24), (byte)(hex >> 16), (byte)(hex >> 8), (byte)(hex >> 0));
  11.     }
  12.  
  13.     public static Color Argb(this int hex)
  14.     {
  15.         return Color.FromArgb((byte)(hex >> 24), (byte)(hex >> 16), (byte)(hex >> 8), (byte)(hex >> 0));
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment