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;
        }
示例#2
0
        /// <summary>
        /// Convert Xamarin.Forms.Color to any IColorSpace
        /// </summary>
        /// <param name="color"></param>
        /// <typeparam name="T">IColorSpace</typeparam>
        public static T To <T>(this Color color) where T : IColorSpace, new()
        {
            var rgb = new Rgb {
                R = color.R * 255,
                G = color.G * 255,
                B = color.B * 255,
            };

            return(rgb.To <T>());
        }
示例#3
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 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;
        }
        private void UpdateHsvFromRgb()
        {
            Rgb rgb = new Rgb() { R = this.red, G = this.green, B = this.blue };
            Hsv hsv = rgb.To<Hsv>();

            if (this.hue != (int)hsv.H)
            {
                this.hue = (int)hsv.H;
                this.OnPropertyChanged("Hue");
            }

            if (this.saturation != (int)(100.0 * hsv.S))
            {
                this.saturation = (int)(100.0 * hsv.S);
                this.OnPropertyChanged("Saturation");
            }

            if (this.value != (int)(100.0 * hsv.V))
            {
                this.value = (int)(100.0 * hsv.V);
                this.OnPropertyChanged("Value");
            }
        }