Exemple #1
0
 public void SetCustomColorByIndex(CustomColor customColor, int index)
 {
     if (index < Colors.Length)
     {
         Colors[index].SetFromCustomColor(customColor);
         ApplyNewColorsToImage();
     }
 }
Exemple #2
0
 public bool Equals(CustomColor customColor) {
     return (R == customColor.R) && (G == customColor.G) && (B == customColor.B) && (A == customColor.A) && (H == customColor.H) && (S == customColor.S) && (L == customColor.L);
 }
Exemple #3
0
 public void SetFromCustomColor(CustomColor customColor) {
     SetFromRGBColor(customColor.R, customColor.G, customColor.B, customColor.A);
 }
Exemple #4
0
        public void ApplyNewColorsToImage()
        {
            Color[] replacedColors;
            Color   currentColor;
            bool    skip;

            Bitmap newBmp = new Bitmap(originalImage);

            if (IsPattern)
            {
                replacedColors = new Color[] { Color.Red, Color.Yellow, Color.White };
            }
            else
            {
                replacedColors = new Color[] { Color.FromArgb(255, 0, 0, 128), Color.FromArgb(255, 0, 255, 128), Color.FromArgb(255, 255, 0, 128) };
            }

            for (int i = 0; i < originalImage.Width; i++)
            {
                for (int j = 0; j < originalImage.Height; j++)
                {
                    skip         = true;
                    currentColor = originalImage.GetPixel(i, j);

                    if (currentColor.A > 16)
                    {
                        for (int k = 0; k < colors.Length && skip; k++)
                        {
                            if (currentColor.GetHue() <= replacedColors[k].GetHue() + 50 && currentColor.GetHue() >= replacedColors[k].GetHue() - 50)
                            {
                                skip = false;
                                newBmp.SetPixel(i, j, IsPattern ? colors[k].DrawingColor : CustomColor.HSLToRGB(colors[k].H, (currentColor.GetSaturation() + colors[k].S) / 2.0f, (currentColor.GetBrightness() + colors[k].L) / 2.0f));
                            }

                            // White is Hue 0, Red is 0 and 360
                            if (IsPattern && currentColor.R == 255 && currentColor.G == 255 && currentColor.B == 255)
                            {
                                newBmp.SetPixel(i, j, colors[2].DrawingColor);
                            }
                        }
                    }
                }
            }
            ImgComponent = SlowBitmap2BitmapImage(newBmp);

            newBmp.Save("testOutput.png", System.Drawing.Imaging.ImageFormat.Png);
        }