Ejemplo n.º 1
0
 private async Task drawBackground(SKCanvas canvas, SSBackgroundGenerator backgroundGenerator)
 {
     var task = Task.Run(() => {
         backgroundGenerator.drawBackground(canvas);
     });
     await task;
 }
Ejemplo n.º 2
0
        public void generate()
        {
            SKBitmap SS = new SKBitmap(model.canvasSize.width, model.canvasSize.height);

            using (SKCanvas canvas = new SKCanvas(SS)) {
                using (SSBackgroundGenerator bgGenerator = new SSBackgroundGenerator(model.background, model.canvasSize)) {
                    loadAndDecodeBitmaps(canvas, bgGenerator);
                }
                drawLayers(canvas);
            }
            SkiaHelper.saveBitmap(SS, model.savePath, model.encoding);
            Console.WriteLine("SS saved to " + model.savePath);
        }
Ejemplo n.º 3
0
        private void loadAndDecodeBitmaps(SKCanvas canvas, SSBackgroundGenerator backgroundGenerator)
        {
            var tasks = new List <Task>();

            tasks.Add(drawBackground(canvas, backgroundGenerator));
            foreach (SSLayer layer in model.layers)
            {
                foreach (SSDevice device in layer.devices)
                {
                    tasks.Add(device.loadFrame());
                    tasks.Add(device.loadScreen(canvas, backgroundGenerator));
                }
            }
            Task.WaitAll(tasks.ToArray());
        }
Ejemplo n.º 4
0
 public async Task loadScreen(SKCanvas canvas, SSBackgroundGenerator backgroundGenerator)
 {
     var task = Task.Run(() => {
         var size          = (SSSize)screenSize;
         SKBitmap ssBitmap = SkiaHelper.createPersistentBitmap(screenshotPath, size.width, size.height);
         backgroundGenerator.drawAdaptiveBackground(canvas, ssBitmap);
         if (size.width != ssBitmap.Width || size.height != ssBitmap.Height)
         {
             Print.Warning("Screenshot size is wrong, resizing screenshot...");
             var info = new SKImageInfo(size.width, size.height);
             ssBitmap = ssBitmap.Resize(info, SKFilterQuality.High);
         }
         screen = SkiaHelper.scaleBitmap(ssBitmap, frameScale);
     });
     await task;
 }