ColorSpace.ColorVector.ToColor C# (CSharp) Method

ToColor() public method

public ToColor ( ) : Color
return Color
        public Color ToColor()
        {
            double min = Math.Min(Math.Min(Component1, Component2), Component3);
            double max = Math.Max(Math.Max(Component1, Component2), Component3);

            if (min >= 0 && max <= 1)
            {
                return Color.FromArgb(ToColorComponent(Component1), ToColorComponent(Component2), ToColorComponent(Component3));
            }
            else
            {
                return Color.Transparent;
            }
        }

Usage Example

Beispiel #1
0
        private static void GenerateXyyColors(Bitmap bitmap, double bigY)
        {
            double width = bitmap.Width - 1;
            double height = bitmap.Width - 1;

            for (int y = 0; y < bitmap.Height; y++)
            {
                for (int x = 0; x <= y; x++)
                {
                    double cx = (x + 0.5) / width;
                    double cy = 1.0 - (y + 0.5) / height;

                    ColorVector colorVector = new ColorVector()
                    {
                        Component1 = cx,
                        Component2 = cy,
                        Component3 = bigY
                    };

                    colorVector.ConvertXyyToLinearSRgb();

                    if (colorVector.IsCanonical())
                    {
                        colorVector.ConvertLinearSRgbToSRgb();

                        bitmap.SetPixel(x, y, colorVector.ToColor());
                    }
                }
            }
        }
All Usage Examples Of ColorSpace.ColorVector::ToColor