예제 #1
0
 public async Task loadFrame()
 {
     var task = Task.Run(() => {
         var size             = (SSSize)this.screenSize;
         var path             = Path.Combine(Config.shared.appPath, "builder/public/static/frames", framePath);
         SKBitmap frameBitmap = SkiaHelper.createPersistentBitmap(path, size.width + 100, size.height + 100);
         frame = SkiaHelper.scaleBitmap(frameBitmap, frameScale);
     });
     await task;
 }
예제 #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);
        }
예제 #3
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;
 }
예제 #4
0
        private SKBitmap createDevice(SSDevice device, SKCanvas canvas, int deviceId)
        {
            SKBitmap screenShot = createScreen(device, canvas, deviceId);
            SKBitmap frame      = createFrame(device);
            var      ssPosX     = Convert.ToInt32(device.screenOffset?.x * device.frameScale);
            var      ssPosY     = Convert.ToInt32(device.screenOffset?.y * device.frameScale);

            Tuple <SKBitmap, SKPoint>[] bitMapsToCombine =
            {
                Tuple.Create(frame,      new SKPoint(0,      0)),
                Tuple.Create(screenShot, new SKPoint(ssPosX, ssPosY))
            };
            SKBitmap deviceBitmap = SkiaHelper.overlayBitmaps(bitMapsToCombine);

            if (device.rotation.HasValue && device.rotation > 0)
            {
                SKBitmap rotatedDeviceBitmap = SkiaHelper.rotateBitmap(deviceBitmap, device.rotation ?? 0);
                return(rotatedDeviceBitmap);
            }
            return(deviceBitmap);
        }
예제 #5
0
        private void drawImageBackground(SKCanvas canvas)
        {
            SKBitmap bgBitmap = SkiaHelper.createPersistentBitmap(background.imagePath, canvasSize.width, canvasSize.height);

            if (bgBitmap.Width != canvasSize.width || bgBitmap.Height != canvasSize.height)
            {
                var info = new SKImageInfo(canvasSize.width, canvasSize.height);
                bgBitmap = bgBitmap.Resize(info, SKFilterQuality.High);
            }

            if (background.blur.HasValue && background.blur != 0)
            {
                var filter = SKImageFilter.CreateBlur((int)background.blur, (int)background.blur);
                var paint  = new SKPaint {
                    ImageFilter = filter
                };
                canvas.DrawBitmap(bgBitmap, new SKPoint(0, 0), paint);
            }
            else
            {
                canvas.DrawBitmap(bgBitmap, new SKPoint(0, 0));
            }
        }