Exemplo n.º 1
0
        public void Render(RenderTree renderTree)
        {
            var image  = _renderer.Render(renderTree);
            var stream = new MemoryStream();

            image.SaveAsBmp(stream);
            viewOutput.Image = Image.FromStream(stream);
        }
Exemplo n.º 2
0
        private static int RunApplication(Options options)
        {
            if (!File.Exists(options.InputFile))
            {
                Console.Error.WriteLine("File not found: {0}", options.InputFile);
                return(1);
            }

            var package = LoadPackageFromChunk(options.InputFile);

            PackageDumper.DumpPackage(package);

            var outputFile = options.OutputFile;

            if (!string.IsNullOrWhiteSpace(outputFile))
            {
                var renderer = new ImageRenderTreeRenderer();
                renderer.LoadTextures(options.TextureDir);
                var img = renderer.Render(RenderTree.Create(package));
                using var fs = File.OpenWrite(outputFile);
                img.SaveAsPng(fs);

                if (!options.NoOpen)
                {
                    Process.Start(new ProcessStartInfo(outputFile)
                    {
                        UseShellExecute = true
                    });
                }
            }

            //Console.WriteLine(JsonConvert.SerializeObject(package, Formatting.Indented, new JsonSerializerSettings()
            //{
            //    TypeNameHandling = TypeNameHandling.Auto,
            //    PreserveReferencesHandling = PreserveReferencesHandling.Objects,
            //    Converters =
            //    {
            //        new StringEnumConverter(new DefaultNamingStrategy())
            //    }
            //}));

            return(0);
        }