27 lines
709 B
C#
27 lines
709 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace UtilLib
|
|
{
|
|
public class Colors
|
|
{
|
|
public static Color FromHex(string hex)
|
|
{
|
|
hex = hex.TrimStart('#');
|
|
int hexValue = Convert.ToInt32(hex, 16);
|
|
byte red = (byte)((hexValue >> 16) & 0xFF);
|
|
byte green = (byte)((hexValue >> 8) & 0xFF);
|
|
byte blue = (byte)(hexValue & 0xFF);
|
|
return FromRGB(red, green, blue);
|
|
}
|
|
public static Color FromRGB(byte red, byte green, byte blue)
|
|
{
|
|
return Color.FromArgb(red, green, blue);
|
|
}
|
|
}
|
|
}
|