Beispiel #1
0
//
//        public void ResetColorChip()
//        {
//            // Clear the colors first
////            colorChip.Clear();
//
//            currentStep++;
//        }

        public void UpdateColors()
        {
            for (var i = 0; i < totalColors; i++)
            {
                var tmpColor = colors[i];
                var hex      = ColorUtils.RgbToHex(tmpColor.R, tmpColor.G, tmpColor.B);

                colorChip.UpdateColorAt(i, hex);
            }

            currentStep++;
        }
Beispiel #2
0
        public void UpdateColors()
        {
            for (var i = 0; i < totalColors; i++)
            {
                var tmpColor = colors[i];
                var hex      = ColorData.ColorToHex(tmpColor.r, tmpColor.g, tmpColor.b);

                colorChip.UpdateColorAt(i, hex);
            }

            currentStep++;
        }
Beispiel #3
0
        public void ParseFlagColors()
        {
            var newFlagColors = new List <string>();

            if (bytes == null)
            {
                newFlagColors = flagColors.ToList();
            }
            else
            {
                // TODO This is broken?

                var total = imageParser.colorPalette.Count;

                for (int i = 0; i < total; i++)
                {
                    newFlagColors.Add(((ColorData)imageParser.colorPalette[i]).ToHex());
                }

//                var pixels = tex.GetPixels();
//
//                var total = pixels.Length;
//
//                for (int i = 0; i < total; i++)
//                {
//                    var color = pixels[i];
//                    var hex = ColorData.ColorToHex(color.r, color.g, color.b);
//
//
//
//                    if (color.a == 1f && !Equals(color, maskColor))
//                    {
//                        if (newFlagColors.IndexOf(hex) == -1)
//                        {
//
//                            newFlagColors.Add(hex);
//
//                        }
//                    }
//
//                }
            }

            flagColorChip.total = newFlagColors.Count;

            for (int i = 0; i < newFlagColors.Count; i++)
            {
                flagColorChip.UpdateColorAt(i, newFlagColors[i]);
            }

            currentStep++;
        }
Beispiel #4
0
        public Image ReadImage(WorkspacePath src, string maskHex = "#ff00ff", string[] colorRefs = null)
        {
            PNGReader reader = null;

            using (var memoryStream = new MemoryStream())
            {
                using (var fileStream = workspace.OpenFile(src, FileAccess.Read))
                {
                    fileStream.CopyTo(memoryStream);
                    fileStream.Close();
                }

                reader = new PNGReader(memoryStream.ToArray(), maskHex);
            }

            var tmpColorChip = new ColorChip();



            var imageParser = new SpriteImageParser(reader, tmpColorChip);

            // Manually call each step
            imageParser.ParseImageData();

            // If no colors are passed in, used the image's palette
            if (colorRefs == null)
            {
                colorRefs = reader.colorPalette.Select(c => ColorUtils.RgbToHex(c.R, c.G, c.B)).ToArray();
            }

            // Resize the color chip
            tmpColorChip.total = colorRefs.Length;

            // Add the colors
            for (int i = 0; i < colorRefs.Length; i++)
            {
                tmpColorChip.UpdateColorAt(i, colorRefs[i]);
            }

            // Parse the image with the new colors
            imageParser.CreateImage();

            // Return the new image from the parser
            return(imageParser.image);
        }
        public void ParseFlagColors()
        {
            var newFlagColors = new List <string>();

            if (flagTex == null)
            {
                newFlagColors = flagColors.ToList();
            }
            else
            {
                var pixels = flagTex.GetPixels();

                var total = pixels.Length;

                for (int i = 0; i < total; i++)
                {
                    var color = pixels[i];
                    var hex   = ColorData.ColorToHex(color.r, color.g, color.b);



                    if (color.a == 1f && !Equals(color, maskColor))
                    {
                        if (newFlagColors.IndexOf(hex) == -1)
                        {
                            newFlagColors.Add(hex);
                        }
                    }
                }
            }

            flagColorChip.RebuildColorPages(newFlagColors.Count);

            for (int i = 0; i < newFlagColors.Count; i++)
            {
                flagColorChip.UpdateColorAt(i, newFlagColors[i]);
            }

            currentStep++;
        }