Beispiel #1
0
        private static void Main(string[] args)
        {
            var testCount = 10;

            var randomizer   = new AssetRandomizer();
            var imageBuilder = new SkiaImageBuilder();

            randomizer.ClearOutputPath();

            var jobTimer = new Stopwatch();

            jobTimer.Start();
            Console.WriteLine("Drawing Test Images with SkiaSharp in .NET Core 2.1...");
            for (var i = 1; i <= testCount; i++)
            {
                Console.WriteLine("Drawing Image {0}", i);
                imageBuilder.BuildSingleTestImage(randomizer, i);
            }

            Console.WriteLine("Drawing Test Complete");
            jobTimer.Stop();
            Console.WriteLine(
                "Drew {0} images in {1:F2} seconds. Any key to exit.",
                testCount,
                jobTimer.Elapsed.TotalSeconds);
            Console.ReadKey();
        }
Beispiel #2
0
        public override void PostProcess()
        {
            int threadCount = Math.Max(Environment.ProcessorCount - 2, 1);

            IProcessor <PointData> fractalProcessor    = InitializeRenderer(DestImage.Width, DestImage.Height);
            IProcessor <double>    innerColorProcessor = new ColorProcessor <SingleColorAlgorithm>(DestImage.Width, DestImage.Height);
            IProcessor <double>    outerColorProcessor = new ColorProcessor <SmoothColoringAlgorithm>(DestImage.Width, DestImage.Height);

            SkiaImageBuilder imageBuilder = new SkiaImageBuilder(DestImage);

            fractalProcessor.SetupAsync(new ProcessorConfig
            {
                ThreadCount = threadCount,
                Params      = GetParams()
            }, CancellationToken.None).Wait();
            PointData[,] inputData = fractalProcessor.ProcessAsync(CancellationToken.None).Result;

            innerColorProcessor.SetupAsync(new ColorProcessorConfig
            {
                ThreadCount = threadCount,
                Params      = new EmptyColoringParams(),
                PointClass  = PointClass.Inner,
                InputData   = inputData
            }, CancellationToken.None).Wait();
            double[,] innerIndicies = innerColorProcessor.ProcessAsync(CancellationToken.None).Result;

            outerColorProcessor.SetupAsync(new ColorProcessorConfig
            {
                ThreadCount = threadCount,
                Params      = new EmptyColoringParams(),
                PointClass  = PointClass.Outer,
                InputData   = inputData
            }, CancellationToken.None).Wait();
            double[,] outerIndicies = outerColorProcessor.ProcessAsync(CancellationToken.None).Result;

            imageBuilder.CreateImage(outerIndicies, innerIndicies, OuterColors, InnerColors);
        }