Beispiel #1
0
            public void WhiteRgbToLch()
            {
				var knownColor = new Rgb { R = 255, G = 255, B = 255, };
				var expectedColor = new Lch { L = 100, C = .01166, H = 296.813, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
 protected PaletteTile(int id, double widthAndHeight, Rgb rgb)
 {
     Id = id;
     Width = widthAndHeight;
     Height = widthAndHeight;
     Rgb = rgb;
 }
Beispiel #3
0
            public void WhiteRgbToRgb()
            {
				var knownColor = new Rgb { R = 255, G = 255, B = 255, };
				var expectedColor = new Rgb { R = 255, G = 255, B = 255, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #4
0
            public void WhiteRgbToHsl()
            {
				var knownColor = new Rgb { R = 255, G = 255, B = 255, };
				var expectedColor = new Hsl { H = 0, S = 0, L = 100, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #5
0
            public void WhiteRgbToLab()
            {
				var knownColor = new Rgb { R = 255, G = 255, B = 255, };
				var expectedColor = new Lab { L = 100, A = 0.00526, B = -.0104, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
        public double GetDifferenceUsingCie1976Comparison(Rgb color1, Rgb color2)
        {
            var colorRgb1 = new Rgb { R = color1.R, G = color1.G, B = color1.B };
            var colorRgb2 = new Rgb { R = color2.R, G = color2.G, B = color2.B };

            return _comparer.Compare(colorRgb1, colorRgb2);
        }
Beispiel #7
0
            public void WhiteRgbToCmyk()
            {
				var knownColor = new Rgb { R = 255, G = 255, B = 255, };
				var expectedColor = new Cmyk { C = 0, M = 0, Y = 0, K = 0, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
        public static List<LabInfo> ToListLabInfo(List<PixelInfo> pixelInfo)
        {
            var labInfo = new List<LabInfo>();

            var labList = new List<Lab>();

            var listColors = new List<Color>();
            var listLabLists = new List<List<Lab>>();

            foreach (var pixInfo in pixelInfo)
            {
                foreach (var pix in pixInfo.PixelData)
                {
                    var rgb = new Rgb();
                    rgb.R = pix.red;
                    rgb.G = pix.green;
                    rgb.B = pix.blue;
                    labList.Add(rgb.To<Lab>());
                }
                listLabLists.Add(new List<Lab>(labList));
                listColors.Add(pixInfo.Color);
                labList.Clear();
            }

            for (int i = 0; i < listColors.Count; i++)
            {
                labInfo.Add(new LabInfo(listLabLists[i], listColors[i]));
            }

            return labInfo;
        }
Beispiel #9
0
            public void WhiteRgbToXyz()
            {
				var knownColor = new Rgb { R = 255, G = 255, B = 255, };
				var expectedColor = new Xyz { X = 95.050, Y = 100, Z = 108.900, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #10
0
            public void DarkVioletCmykToRgb()
            {
                var knownColor = new Cmyk { C = .29858, M = 1, Y = 0, K = .17255, };
                var expectedColor = new Rgb { R = 148, G = 0, B = 211, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #11
0
        private static Xyz RGBtoXYZ(Color color)
        {
            ColorMine.ColorSpaces.Rgb c1 = new ColorMine.ColorSpaces.Rgb()
            {
                R = color.R,
                G = color.G,
                B = color.B
            };

            return(c1.To <ColorMine.ColorSpaces.Xyz>());
        }
            public void ReturnsZeroForSameColors()
            {
                var compareColor = new Rgb {R = 140, G = 130, B = 23};
                // Todo, should be mocking!!
                var a = new Rgb();
                a.Initialize(compareColor);

                var b = new Rgb();
                b.Initialize(compareColor);

                ReturnsExpectedValueForKnownInput(0.0, a, b);
            }
        public static List<Lab> ToLabData(List<PixelData> pixelData)
        {
            var labData = new List<Lab>();

            foreach (var pix in pixelData)
            {
                var rgb = new Rgb();
                rgb.R = pix.red;
                rgb.G = pix.green;
                rgb.B = pix.blue;
                labData.Add(rgb.To<Lab>());
            }
            return labData;
        }
        public PaletteTile FindBestTile(Rgb rgb)
        {
            var minimumDeltaE = double.MaxValue;
            PaletteTile result = null;
            foreach (var tileInfo in _tiles)
            {
                var deltaE = GetDifferenceUsingCie1976Comparison(tileInfo.Rgb, rgb);
                if (deltaE < minimumDeltaE)
                {
                    minimumDeltaE = deltaE;
                    result = tileInfo;
                }
            }

            return result;
        }
        public Rgb Calculate(Bitmap bitmap)
        {
            double rSum = 0;
            double gSum = 0;
            double bSum = 0;

            for (var y = 0; y < bitmap.Height; y++)
            {
                for (var x = 0; x < bitmap.Width; x++)
                {
                    var pixel = bitmap.GetPixel(x, y);
                    var rgb = new Rgb{ R = pixel.R, G = pixel.G, B = pixel.B };
                    //  var lab= rgb.To<Lab>();

                    rSum += rgb.R;
                    gSum += rgb.G;
                    bSum += rgb.B;
                }
            }

            var pixelCount = bitmap.Width * bitmap.Height;

            return new Rgb(rSum / pixelCount, gSum / pixelCount, bSum / pixelCount);
        }
Beispiel #16
0
            public void GoldenrodRgbToYxy()
            {
                var knownColor = new Rgb { R = 218, G = 165, B = 32, };
                var expectedColor = new Yxy { Y1 = 41.920, X = .46457, Y2 = .45684, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #17
0
            public void GoldenrodRgbToXyz()
            {
                var knownColor = new Rgb { R = 218, G = 165, B = 32, };
                var expectedColor = new Xyz { X = 42.629, Y = 41.920, Z = 7.211, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #18
0
            public void GoldenrodRgbToRgb()
            {
                var knownColor = new Rgb { R = 218, G = 165, B = 32, };
                var expectedColor = new Rgb { R = 218, G = 165, B = 32, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #19
0
            public void GoldenrodRgbToLch()
            {
                var knownColor = new Rgb { R = 218, G = 165, B = 32, };
                var expectedColor = new Lch { L = 70.816, C = 69.291, H = 82.933, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #20
0
            public void GoldenrodRgbToLab()
            {
                var knownColor = new Rgb { R = 218, G = 165, B = 32, };
                var expectedColor = new Lab { L = 70.816, A = 8.525, B = 68.765, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #21
0
            public void GoldenrodRgbToHsl()
            {
                var knownColor = new Rgb { R = 218, G = 165, B = 32, };
                var expectedColor = new Hsl { H = 43, S = 74, L = 49, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #22
0
            public void MaroonLchToRgb()
            {
                var knownColor = new Lch { L = 24.829, C = 60.093, H = 38.180, };
                var expectedColor = new Rgb { R = 125, G = 0.02, B = 0, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #23
0
            public void GoldenrodRgbToCmy()
            {
                var knownColor = new Rgb { R = 218, G = 165, B = 32, };
                var expectedColor = new Cmy { C = .14510, M = .35294, Y = .87451, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #24
0
            public void BlackRgbToYxy()
            {
                var knownColor = new Rgb { R = 0, G = 0, B = 0, };
                var expectedColor = new Yxy { Y1 = 0, X = 0, Y2 = 0, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #25
0
            public void BlackRgbToXyz()
            {
                var knownColor = new Rgb { R = 0, G = 0, B = 0, };
                var expectedColor = new Xyz { X = 0, Y = 0, Z = 0, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #26
0
            public void BlackRgbToLch()
            {
                var knownColor = new Rgb { R = 0, G = 0, B = 0, };
                var expectedColor = new Lch { L = 0, C = 0, H = 0, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #27
0
            public void BlackRgbToLab()
            {
                var knownColor = new Rgb { R = 0, G = 0, B = 0, };
                var expectedColor = new Lab { L = 0, A = 0, B = 0, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #28
0
            public void BlackRgbToHsl()
            {
                var knownColor = new Rgb { R = 0, G = 0, B = 0, };
                var expectedColor = new Hsl { H = 0, S = 0, L = 0, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #29
0
            public void WhiteRgbToYxy()
            {
                var knownColor = new Rgb { R = 255, G = 255, B = 255, };
                var expectedColor = new Yxy { Y1 = 100, X = .31272, Y2 = .32900, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #30
0
            public void GoldenrodRgbToCmyk()
            {
                var knownColor = new Rgb { R = 218, G = 165, B = 32, };
                var expectedColor = new Cmyk { C = 0, M = .24312, Y = .85321, K = .14510, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #31
0
            public void BlackRgbToCmyk()
            {
                var knownColor = new Rgb { R = 0, G = 0, B = 0, };
                var expectedColor = new Cmyk { C = 0, M = 0, Y = 0, K = 1, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Beispiel #32
0
 public static Color ToColor(this Rgb _this)
 {
     return(Color.FromArgb((int)_this.R, (int)_this.G, (int)_this.B));
 }