예제 #1
0
 void StringToARGB(string value, byte alpha, byte red, byte green, byte blue)
 {
     Colorer.StringToARGB(value, out var alphaOut, out var redOut, out var greenOut, out var blueOut);
     Assert.AreEqual(alpha, alphaOut);
     Assert.AreEqual(red, redOut);
     Assert.AreEqual(green, greenOut);
     Assert.AreEqual(blue, blueOut);
 }
예제 #2
0
 static string OverlayColor(string color1, string color2)
 {
     Colorer.StringToARGB(color1, out byte alpha1, out byte red1, out byte green1, out byte blue1);
     Colorer.StringToARGB(color2, out byte alpha2, out byte red2, out byte green2, out byte blue2);
     red1   = (byte)((red1 * alpha1 / 255) + (red2 * alpha2 * (255 - alpha1) / (255 * 255)));
     green1 = (byte)((green1 * alpha1 / 255) + (green2 * alpha2 * (255 - alpha1) / (255 * 255)));
     blue1  = (byte)((blue1 * alpha1 / 255) + (blue2 * alpha2 * (255 - alpha1) / (255 * 255)));
     alpha1 = (byte)(alpha1 + (alpha2 * (255 - alpha1) / 255));
     return(Colorer.ARGBToString(alpha1, red1, green1, blue1));
 }
예제 #3
0
 static string AddColor(string color1, string color2)
 {
     Colorer.StringToARGB(color1, out var alpha1, out var red1, out var green1, out var blue1);
     Colorer.StringToARGB(color2, out var alpha2, out var red2, out var green2, out var blue2);
     alpha1 = (byte)Math.Max(0, Math.Min(alpha1 + alpha2, 255));
     red1   = (byte)Math.Max(0, Math.Min(red1 + red2, 255));
     green1 = (byte)Math.Max(0, Math.Min(green1 + green2, 255));
     blue1  = (byte)Math.Max(0, Math.Min(blue1 + blue2, 255));
     return(Colorer.ARGBToString(alpha1, red1, green1, blue1));
 }
        ImageGrabColorDialog(string color)
        {
            InitializeComponent();

            try
            {
                Colorer.StringToARGB(color, out var alpha, out var red, out var green, out var blue);
                Alpha = alpha;
                Red   = red;
                Green = green;
                Blue  = blue;
            }
            catch { Alpha = Red = Green = Blue = 255; }
        }
예제 #5
0
 static string AdjustColor(string color, double multiplier, bool doAlpha, bool doRed, bool doGreen, bool doBlue)
 {
     Colorer.StringToARGB(color, out var alpha, out var red, out var green, out var blue);
     if (doAlpha)
     {
         alpha = (byte)Math.Max(0, Math.Min((int)(alpha * multiplier + 0.5), 255));
     }
     if (doRed)
     {
         red = (byte)Math.Max(0, Math.Min((int)(red * multiplier + 0.5), 255));
     }
     if (doGreen)
     {
         green = (byte)Math.Max(0, Math.Min((int)(green * multiplier + 0.5), 255));
     }
     if (doBlue)
     {
         blue = (byte)Math.Max(0, Math.Min((int)(blue * multiplier + 0.5), 255));
     }
     return(Colorer.ARGBToString(alpha, red, green, blue));
 }
 public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
 {
     Colorer.StringToARGB(value as string, out byte alpha, out byte red, out byte green, out byte blue);
     return(new object[] { alpha, red, green, blue });
 }