Ejemplo n.º 1
0
        public SkiaBitmapExportContext(
            int width,
            int height,
            float displayScale,
            int dpi            = 72,
            bool disposeBitmap = true,
            bool transparent   = true) : base(width, height, dpi)
        {
            if (transparent)
            {
                var imageInfo = new SKImageInfo(width, height, SKColorType.Rgba8888, SKAlphaType.Premul);
                _surface = SKSurface.Create(imageInfo);
            }
            else
            {
                var imageInfo = new SKImageInfo(width, height, SKColorType.Rgb565, SKAlphaType.Opaque);
                _surface = SKSurface.Create(imageInfo);
            }

            if (_surface == null)
            {
                Logger.Warn("Unable to create a Skia surface");
                return;
            }

            _skiaCanvas = _surface.Canvas;
            var nativeCanvas = new SkiaCanvas
            {
                Canvas       = _skiaCanvas,
                DisplayScale = displayScale
            };

            _canvas        = new ScalingCanvas(nativeCanvas);
            _disposeBitmap = disposeBitmap;
        }
 public WDSkiaDirectRenderer()
 {
     _canvas        = new SkiaCanvas();
     _scalingCanvas = new ScalingCanvas(_canvas);
 }