Пример #1
0
        private static void SaveAsPng(string gpFile, string pngDirectory)
        {
            IRenderer renderer = new BitmapRenderer();

            var imagePaletteBytes = new Extractor().GetPaletteBytes(gpFile);
            var extractResult = new Extractor().GetImagesFromOutput(gpFile).ToList();

            var rawParser = new RawParser();

            var paletteBytes = File.ReadAllBytes(@"..\..\..\..\palette\0\agew_1.pal");
            var colorCollection = rawParser.GetColorCollectionFromPalleteFile(paletteBytes);

            var imagePaletteColors = ImageGenerator.OffsetsToColors(imagePaletteBytes, colorCollection);

            var nationColorOffset = NationColorOffset.Red;

            using (var bitMap = new Runner().Run(extractResult, nationColorOffset, 0, rawParser, renderer, imagePaletteColors, colorCollection))
            {
                using (var stream = new MemoryStream())
                {
                    bitMap.Save(stream, ImageFormat.Png);
                    File.WriteAllBytes(Path.Combine(pngDirectory, Path.GetFileNameWithoutExtension(gpFile) + ".png"),
                        stream.ToArray());
                }
            }
        }
Пример #2
0
        private void Do()
        {
            var filePath = @"../../../../gp/test.gp";

            var imagePaletteBytes = new Extractor().GetPaletteBytes(filePath);
            var extractResult = new Extractor().GetImagesFromOutput(filePath).ToList();

            IRenderer renderer = new BitmapRenderer();

            var paletteBytes = File.ReadAllBytes(@"../../../../palette/0/agew_1.pal");

            var rawParser = new RawParser();

            var colorCollection = rawParser.GetColorCollectionFromPalleteFile(paletteBytes);

            var imagePaletteColors = ImageGenerator.OffsetsToColors(imagePaletteBytes, colorCollection);

            var nationColorOffset = NationColorOffset.Blue;

            //Watch(extractResult);

            var bitmapList = DrawImage(extractResult, nationColorOffset, extractResult.Count, rawParser, renderer, imagePaletteColors, colorCollection);

            var itemsForListBox = Enumerable.Range(0, bitmapList.Count).Select(it => it.ToString()).ToList();

            listBox1.DataSource = itemsForListBox;

            listBox1.SelectedIndexChanged += (sender, args) =>
            {
                if ((sender as ListBox).SelectedIndex > -1)
                pictureBox2.Image = bitmapList[(sender as ListBox).SelectedIndex];
            };

            listBox1.ClearSelected();
            listBox1.SelectedIndex = 0;
        }