Ejemplo n.º 1
0
            private void UpdateImage()
            {
                double hue        = hueValue;
                double saturation = 0f;
                double value      = 1f;

                var imageWidth  = image.Width;
                var imageHeight = image.Height;

                for (int i = 0; i < imageWidth; i++)
                {
                    saturation = (float)i / imageWidth;

                    for (int k = 0; k < imageHeight; k++)
                    {
                        value = (float)k / imageHeight;

                        // HSL to RGB convertion.
                        Color pixelColor = ColorTranslatorEx.FromHSV(hue * 359, saturation, value);
                        image.SetPixel(i, k, pixelColor);
                    }
                }

                image.Apply();
            }
Ejemplo n.º 2
0
        private void UpdateControlsFromRGB()
        {
            Color rgbColor = Color.FromArgb(Convert.ToInt32(rNumeric.Value), Convert.ToInt32(gNumeric.Value), Convert.ToInt32(bNumeric.Value));

            double hue;
            double saturation;
            double value;

            ColorTranslatorEx.ToHSV(rgbColor, out hue, out saturation, out value);
            hue /= 359;

            huePicker.HueChanged -= huePicker_HueChanged;
            huePicker.Hue         = hue;
            huePicker.HueChanged += huePicker_HueChanged;
            vsPicker.SetHue(hue);
            vsPicker.ValueChanged      -= VsPickerValueChanged;
            vsPicker.Value              = (float)value;
            vsPicker.ValueChanged      += VsPickerValueChanged;
            vsPicker.SaturationChanged -= VsPickerSaturationChanged;
            vsPicker.Saturation         = (float)saturation;
            vsPicker.SaturationChanged += VsPickerSaturationChanged;

            hueNumeric.ValueChanged        -= HueNumericValueChanged;
            hueNumeric.Value                = Convert.ToInt32(hue * 359);
            hueNumeric.ValueChanged        += HueNumericValueChanged;
            saturationNumeric.ValueChanged -= SaturationNumericValueChanged;
            saturationNumeric.Value         = Convert.ToInt32(saturation * 255);
            saturationNumeric.ValueChanged += SaturationNumericValueChanged;
            valueNumeric.ValueChanged      -= ValueNumericValueChanged;
            valueNumeric.Value              = Convert.ToInt32(value * 255);
            valueNumeric.ValueChanged      += ValueNumericValueChanged;

            rNumeric.ValueChanged -= rNumeric_ValueChanged;
            rNumeric.Value         = rgbColor.R;
            rNumeric.ValueChanged += rNumeric_ValueChanged;
            gNumeric.ValueChanged -= gNumeric_ValueChanged;
            gNumeric.Value         = rgbColor.G;
            gNumeric.ValueChanged += gNumeric_ValueChanged;
            bNumeric.ValueChanged -= bNumeric_ValueChanged;
            bNumeric.Value         = rgbColor.B;
            bNumeric.ValueChanged += bNumeric_ValueChanged;

            color = Color.FromArgb((int)(alphaPicker.Alpha * 255), rgbColor);

            OnColorChanged(EventArgs.Empty);
        }
Ejemplo n.º 3
0
        private void VsPickerSaturationChanged(object sender, EventArgs e)
        {
            saturationNumeric.ValueChanged -= SaturationNumericValueChanged;
            saturationNumeric.Value         = (int)(vsPicker.Saturation * 255);
            saturationNumeric.ValueChanged += SaturationNumericValueChanged;

            Color rgbColor = ColorTranslatorEx.FromHSV(huePicker.Hue * 359, vsPicker.Saturation, vsPicker.Value);

            rNumeric.ValueChanged -= rNumeric_ValueChanged;
            rNumeric.Value         = rgbColor.R;
            rNumeric.ValueChanged += rNumeric_ValueChanged;
            gNumeric.ValueChanged -= gNumeric_ValueChanged;
            gNumeric.Value         = rgbColor.G;
            gNumeric.ValueChanged += gNumeric_ValueChanged;
            bNumeric.ValueChanged -= bNumeric_ValueChanged;
            bNumeric.Value         = rgbColor.B;
            bNumeric.ValueChanged += bNumeric_ValueChanged;

            color = Color.FromArgb((int)(alphaPicker.Alpha * 255), rgbColor);
            ColorChanged(this, null);
        }
Ejemplo n.º 4
0
        private void VsPickerValueChanged(object sender, EventArgs e)
        {
            valueNumeric.ValueChanged -= ValueNumericValueChanged;
            valueNumeric.Value         = (int)(vsPicker.Value * 255);
            valueNumeric.ValueChanged += ValueNumericValueChanged;

            Color rgbColor = ColorTranslatorEx.FromHSV(huePicker.Hue * 359, vsPicker.Saturation, vsPicker.Value);

            rNumeric.ValueChanged -= rNumeric_ValueChanged;
            rNumeric.Value         = rgbColor.R;
            rNumeric.ValueChanged += rNumeric_ValueChanged;
            gNumeric.ValueChanged -= gNumeric_ValueChanged;
            gNumeric.Value         = rgbColor.G;
            gNumeric.ValueChanged += gNumeric_ValueChanged;
            bNumeric.ValueChanged -= bNumeric_ValueChanged;
            bNumeric.Value         = rgbColor.B;
            bNumeric.ValueChanged += bNumeric_ValueChanged;

            color = Color.FromArgb((int)(alphaPicker.Alpha * 255), rgbColor);

            OnColorChanged(EventArgs.Empty);
        }
Ejemplo n.º 5
0
            private void UpdateImage()
            {
                double hue        = 0f;
                double saturation = .9f;
                double luminosity = .5f;

                var imageWidth  = image.Width;
                var imageHeight = image.Height;

                for (int i = 0; i < imageWidth; i++)
                {
                    for (int k = 0; k < imageHeight; k++)
                    {
                        hue = (float)k / imageHeight;

                        // HSL to RGB convertion.
                        var pixelColor = ColorTranslatorEx.FromHsb(hue, saturation, luminosity);
                        image.SetPixel(i, k, pixelColor);
                    }
                }

                image.Apply();
            }
Ejemplo n.º 6
0
        private void huePicker_HueChanged(object sender, EventArgs e)
        {
            vsPicker.SetHue(huePicker.Hue);

            hueNumeric.ValueChanged -= HueNumericValueChanged;
            hueNumeric.Value         = (int)((1f - huePicker.Hue) * 359);
            hueNumeric.ValueChanged += HueNumericValueChanged;

            Color rgbColor = ColorTranslatorEx.FromHSV(huePicker.Hue * 359, vsPicker.Saturation, vsPicker.Value);

            rNumeric.ValueChanged -= rNumeric_ValueChanged;
            rNumeric.Value         = rgbColor.R;
            rNumeric.ValueChanged += rNumeric_ValueChanged;
            gNumeric.ValueChanged -= gNumeric_ValueChanged;
            gNumeric.Value         = rgbColor.G;
            gNumeric.ValueChanged += gNumeric_ValueChanged;
            bNumeric.ValueChanged -= bNumeric_ValueChanged;
            bNumeric.Value         = rgbColor.B;
            bNumeric.ValueChanged += bNumeric_ValueChanged;

            color = Color.FromArgb((int)(alphaPicker.Alpha * 255), rgbColor);
            ColorChanged(this, EventArgs.Empty);
        }