Example #1
0
        public void SaveImage(WorkspacePath dest, Image image)
        {
            var width     = image.width;
            var height    = image.height;
            var hexColors = image.colors;

            // convert colors
            var totalColors = hexColors.Length;
            var colors      = new Color[totalColors];

            for (var i = 0; i < totalColors; i++)
            {
                colors[i] = ColorUtils.HexToColor(hexColors[i]);
            }

            var pixelData = image.pixels;

            var exporter =
                new PixelDataExporter(dest.EntityName, pixelData, width, height, colors, _pngWriter, "#FF00FF");

            exporter.CalculateSteps();

            while (exporter.completed == false)
            {
                exporter.NextStep();
            }

            var output = new Dictionary <string, byte[]>
            {
                { dest.Path, exporter.bytes }
            };

            workspace.SaveExporterFiles(output);
        }
Example #2
0
        public void SetImageAsData(Image image, string maskColor = "#FF00FF")
        {
            try
            {
                var palette = image.colors.Select(ColorUtils.HexToColor).ToArray();

                var imageExporter = new PNGWriter();

                var exporter = new PixelDataExporter(fileName, image.pixels, image.width, image.height, palette, imageExporter,
                                                     maskColor);

                exporter.CalculateSteps();

                while (exporter.completed == false)
                {
                    exporter.NextStep();
                }

                bytes = exporter.bytes;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }