예제 #1
0
        private void ShiftHue()
        {
            if (selectedFileName.Length > 0)
            {
                for (int i = 0; i < actualBitmap.Width; i++)
                {
                    for (int j = 0; j < actualBitmap.Height; j++)
                    {
                        var pix = actualBitmap.GetPixel(i, j);
                        var hue = pix.GetHue() / 360.0F;
                        if ((hue < initialPixel.GetHue() / 360.0F + (float)margin) &&
                            (hue > initialPixel.GetHue() / 360.0F - (float)margin))
                        {
                            if (hue + shift > 1)
                            {
                                hue = (float)(-1 + hue + shift);
                            }
                            else if (hue + shift < 0)
                            {
                                hue = (float)(1 + hue + shift);
                            }
                            else
                            {
                                hue = hue + (float)shift;
                            }

                            var respix = ColorRGB.FromHSLA(hue, pix.GetSaturation(), pix.GetBrightness(), pix.A);
                            actualBitmap.SetPixel(i, j, respix);
                        }
                    }
                }
            }
        }
예제 #2
0
 private void ShiftBrightness(float brightness)
 {
     if (selectedFileName.Length > 0)
     {
         for (int i = 0; i < actualBitmap.Width; i++)
         {
             for (int j = 0; j < actualBitmap.Height; j++)
             {
                 var pix    = actualBitmap.GetPixel(i, j);
                 var bright = pix.GetBrightness();
                 if (bright + brightness < 1 && bright + brightness > 0)
                 {
                     var respix = ColorRGB.FromHSLA(pix.GetHue(), pix.GetSaturation(), bright + brightness, pix.A);
                     actualBitmap.SetPixel(i, j, respix);
                 }
             }
         }
     }
 }