Example #1
0
        public void TestMaui()
        {
            using (var skBmp = new SkiaSharp.SKBitmap(256, 256, false))
            {
                using (var skCanvas = new SkiaSharp.SKCanvas(skBmp))
                {
                    using (var mauiCanvas = new Microsoft.Maui.Graphics.Skia.SkiaCanvas())
                    {
                        mauiCanvas.Canvas = skCanvas;

                        var myCanvas = CanvasWrapper.Create(mauiCanvas);

                        myCanvas.DrawCircle((50, 50), 20, System.Drawing.Color.Red);

                        myCanvas.DrawRectangle((100, 10), (50, 50), System.Drawing.Color.White, 5, 3);
                    }
                }

                using (var memBmp = skBmp.UsingMemoryBitmap())
                {
                    memBmp.AsMemoryBitmap()
                    .ToMemoryBitmap(Pixel.RGBA32.Format)
                    .Save("maui.png");
                }
            }
        }
        void OnCanvasViewPaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs args)
        {
            SkiaSharp.SKImageInfo info    = args.Info;
            SkiaSharp.SKSurface   surface = args.Surface;
            SkiaSharp.SKCanvas    canvas  = surface.Canvas;
            canvas.Clear();
            SkiaSharp.SKRect bounds;
            SkiaSharp.SKPath path = SkiaSharp.SKPath.ParseSvgPathData((string)this.Resources["PathString"]);
            path.GetTightBounds(out bounds);
            SkiaSharp.SKPaint paint = new SkiaSharp.SKPaint
            {
                Style       = SkiaSharp.SKPaintStyle.Stroke,
                Color       = SkiaSharp.SKColors.Black,
                StrokeWidth = 10,
                StrokeCap   = SkiaSharp.SKStrokeCap.Round,
                StrokeJoin  = SkiaSharp.SKStrokeJoin.Round
            };
            canvas.Translate(info.Width / 2, info.Height / 2);

            canvas.Scale(info.Width / (bounds.Width + paint.StrokeWidth),
                         info.Height / (bounds.Height + paint.StrokeWidth));

            canvas.Translate(-bounds.MidX, -bounds.MidY);

            canvas.DrawPath(path, paint);
        }
Example #3
0
 private static void _OnDraw(PointerBitmap ptr, Action <SkiaSharp.SKCanvas> onDraw)
 {
     using (var dst = _Implementation.WrapAsSKBitmap(ptr))
     {
         using (var canvas = new SkiaSharp.SKCanvas(dst))
         {
             onDraw(canvas);
         }
     }
 }
Example #4
0
        public static void Draw(SkiaSharp.SKCanvas skCanvas, SvgFragment svgFragment)
        {
            var references = new HashSet <Uri> {
                svgFragment.OwnerDocument.BaseUri
            };
            var size     = SvgExtensions.GetDimensions(svgFragment);
            var bounds   = SKRect.Create(size);
            var drawable = DrawableFactory.Create(svgFragment, bounds, null, s_assetLoader, references);

            if (drawable is { })
Example #5
0
        public SkiaMemoryAdapter(MemoryBitmap bmp)
        {
            _SourceBitmap = bmp;

            _Handle = bmp.Memory.Pin();

            var ptr = new PointerBitmap(_Handle.Value, bmp.Info);

            _ProxyBitmap   = _Implementation.WrapAsSKBitmap(ptr);
            _DeviceContext = new SkiaSharp.SKCanvas(_ProxyBitmap);
        }
Example #6
0
        public static SkiaSharp.SKBitmap?ToBitmap(this SkiaSharp.SKPicture skPicture, SkiaSharp.SKColor background, float scaleX, float scaleY, SkiaSharp.SKColorType skColorType, SkiaSharp.SKAlphaType skAlphaType, SkiaSharp.SKColorSpace skColorSpace)
        {
            var width  = skPicture.CullRect.Width * scaleX;
            var height = skPicture.CullRect.Height * scaleY;

            if (!(width > 0) || !(height > 0))
            {
                return(null);
            }
            var skImageInfo = new SkiaSharp.SKImageInfo((int)width, (int)height, skColorType, skAlphaType, skColorSpace);
            var skBitmap    = new SkiaSharp.SKBitmap(skImageInfo);

            using var skCanvas = new SkiaSharp.SKCanvas(skBitmap);
            Draw(skPicture, background, scaleX, scaleY, skCanvas);
            return(skBitmap);
        }
        public void Draw(SkiaSharp.SKCanvas canvas)
        {
            var info       = this.info;
            var viewBounds = Bounds;
            var scale      = (float)UIKit.UIScreen.MainScreen.Scale;

            using (var image = new SkiaSharp.SKBitmap(info, info.RowBytes))
            {
                using (var pixels = image.PeekPixels())
                    using (var colorSpace = CGColorSpace.CreateDeviceRGB())
                        using (var ctx = new CGBitmapContext(pixels.GetPixels(), info.Width, info.Height, 8, info.RowBytes, colorSpace, CGBitmapFlags.PremultipliedLast | CGBitmapFlags.ByteOrder32Big))
                        {
                            ctx.ClearRect(viewBounds);
                            ctx.TranslateCTM(0, info.Height);
                            ctx.ScaleCTM(scale, -scale);
                            Layer.RenderInContext(ctx);
                        }
                canvas.DrawBitmap(image, SkiaSharp.SKPoint.Empty);
            }
        }
Example #8
0
 public override void DrawLayer(SkiaSharp.SKCanvas canvas, Matrix3X3 parentMatrix, byte parentAlpha)
 {
     // Do nothing.
 }
Example #9
0
 public void Render(SkiaSharp.SKCanvas canvas)
 {
     throw new NotImplementedException();
 }
Example #10
0
 public static void DrawVerticalLine(this SkiaSharp.SKCanvas canvas, System.Windows.Point begin, System.Windows.Point end, SkiaSharp.SKPaint paint)
 {
 }
Example #11
0
 public abstract void Draw(SkiaSharp.SKCanvas canvas);
 public abstract void DrawHighlighted(Canvas c, IList <Highlight.Highlight> indices);
 public abstract void DrawData(Canvas c);
Example #14
0
        public static byte[] ImageScalingByOversized(string path, int maxWidth, int maxHeight, int quality)
        {
            byte[] bytes = null;
            if (!System.IO.File.Exists(path))
            {
                return(bytes);
            }
            var fileStream = new System.IO.FileStream(path, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);

            if (fileStream.Length > maxLength)
            {
                fileStream.Dispose();
                return(bytes);
            }
            var sKManagedStream = new SkiaSharp.SKManagedStream(fileStream, true);
            var sKBitmap        = SkiaSharp.SKBitmap.Decode(sKManagedStream);

            sKManagedStream.Dispose();

            if (sKBitmap.IsEmpty)
            {
                return(bytes);
            }

            if (maxWidth < 1)
            {
                maxWidth = 1;
            }
            if (maxHeight < 1)
            {
                maxHeight = 1;
            }
            if (quality < 1)
            {
                quality = 1;
            }
            if (quality > 100)
            {
                quality = 100;
            }

            int oW = sKBitmap.Width;
            int oH = sKBitmap.Height;
            int nW = oW;
            int nH = oH;

            if (oW > maxWidth || oH > maxHeight)
            {
                nW = maxWidth;
                nH = maxHeight;
                double ratio = 1;

                if (nW > 0 && nH > 0)
                {
                    ratio = (double)nW / oW;
                    nH    = Convert.ToInt32(oH * ratio);
                    if (maxHeight < nH)
                    {
                        ratio = (double)maxHeight / nH;
                        nW    = Convert.ToInt32(nW * ratio);
                        nH    = maxHeight;
                    }
                }
                if (nW < 1 && nH < 1)
                {
                    nW = oW;
                    nH = oH;
                }
                if (nW < 1)
                {
                    ratio = (double)nH / oH;
                    nW    = Convert.ToInt32(oW * ratio);
                }
                if (nH < 1)
                {
                    ratio = (double)nW / oW;
                    nH    = Convert.ToInt32(oH * ratio);
                }
                var sKBitmap2 = new SkiaSharp.SKBitmap(nW, nH);
                var sKCanvas  = new SkiaSharp.SKCanvas(sKBitmap2);
                var sKPaint   = new SkiaSharp.SKPaint
                {
                    FilterQuality = SkiaSharp.SKFilterQuality.Medium,
                    IsAntialias   = true
                };
                sKCanvas.DrawBitmap(
                    sKBitmap,
                    new SkiaSharp.SKRect
                {
                    Location = new SkiaSharp.SKPoint {
                        X = 0, Y = 0
                    },
                    Size = new SkiaSharp.SKSize {
                        Height = oH, Width = oW
                    }
                },
                    new SkiaSharp.SKRect
                {
                    Location = new SkiaSharp.SKPoint {
                        X = 0, Y = 0
                    },
                    Size = new SkiaSharp.SKSize {
                        Height = nH, Width = nW
                    }
                }, sKPaint);
                sKCanvas.Dispose();
                sKBitmap.Dispose();
                sKBitmap = sKBitmap2;
            }

            var sKImage = SkiaSharp.SKImage.FromBitmap(sKBitmap);

            sKBitmap.Dispose();
            var data = sKImage.Encode(GetImageFormatByPath(path), quality);

            sKImage.Dispose();
            bytes = data.ToArray();
            data.Dispose();

            return(bytes);
        }
Example #15
0
        public static byte[] ImageScalingToRange(string path, int maxWidth, int maxHeight, int quality)
        {
            byte[] bytes = null;
            if (!System.IO.File.Exists(path))
            {
                return(bytes);
            }
            var fileStream = new System.IO.FileStream(path, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read); //fileInfo.OpenRead();

            if (fileStream.Length > maxLength)
            {
                fileStream.Dispose();
                return(bytes);
            }
            var sKManagedStream = new SkiaSharp.SKManagedStream(fileStream, true);
            var sKBitmap        = SkiaSharp.SKBitmap.Decode(sKManagedStream);

            sKManagedStream.Dispose();

            if (sKBitmap.IsEmpty)
            {
                return(bytes);
            }

            if (maxWidth < 1)
            {
                maxWidth = 1;
            }
            if (maxHeight < 1)
            {
                maxHeight = 1;
            }
            if (quality < 1)
            {
                quality = 1;
            }
            if (quality > 100)
            {
                quality = 100;
            }

            int oW = sKBitmap.Width;
            int oH = sKBitmap.Height;
            int nW = oW;
            int nH = oH;

            if (nW < maxWidth && nH < maxHeight)//放大
            {
                if (nW < maxWidth)
                {
                    var r = (double)maxWidth / (double)nW;
                    nW = maxWidth;
                    nH = (int)Math.Floor((double)nH * r);
                }
                if (nH < maxHeight)
                {
                    var r = (double)maxHeight / (double)nH;
                    nH = maxHeight;
                    nW = (int)Math.Floor((double)nW * r);
                }
            }
            //限制超出(缩小)
            if (nW > maxWidth)
            {
                var r = (double)maxWidth / (double)nW;
                nW = maxWidth;
                nH = (int)Math.Floor((double)nH * r);
            }
            if (nH > maxHeight)
            {
                var r = (double)maxHeight / (double)nH;
                nH = maxHeight;
                nW = (int)Math.Floor((double)nW * r);
            }


            var sKBitmap2 = new SkiaSharp.SKBitmap(nW, nH);
            var sKCanvas  = new SkiaSharp.SKCanvas(sKBitmap2);
            var sKPaint   = new SkiaSharp.SKPaint
            {
                FilterQuality = SkiaSharp.SKFilterQuality.Medium,
                IsAntialias   = true
            };

            sKCanvas.DrawBitmap(
                sKBitmap,
                new SkiaSharp.SKRect
            {
                Location = new SkiaSharp.SKPoint {
                    X = 0, Y = 0
                },
                Size = new SkiaSharp.SKSize {
                    Height = oH, Width = oW
                }
            },
                new SkiaSharp.SKRect
            {
                Location = new SkiaSharp.SKPoint {
                    X = 0, Y = 0
                },
                Size = new SkiaSharp.SKSize {
                    Height = nH, Width = nW
                }
            }, sKPaint);
            sKCanvas.Dispose();
            var sKImage2 = SkiaSharp.SKImage.FromBitmap(sKBitmap2);

            sKBitmap2.Dispose();
            var data = sKImage2.Encode(GetImageFormatByPath(path), quality);

            sKImage2.Dispose();
            bytes = data.ToArray();
            data.Dispose();

            return(bytes);
        }
Example #16
0
        public static byte[] ImageMaxCutByCenter(string path, int saveWidth, int saveHeight, int quality)
        {
            byte[] bytes = null;
            if (!System.IO.File.Exists(path))
            {
                return(bytes);
            }
            var fileStream = new System.IO.FileStream(path, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read); //fileInfo.OpenRead();

            if (fileStream.Length > maxLength)
            {
                fileStream.Dispose();
                return(bytes);
            }
            var sKManagedStream = new SkiaSharp.SKManagedStream(fileStream, true);
            var sKBitmap        = SkiaSharp.SKBitmap.Decode(sKManagedStream);

            sKManagedStream.Dispose();

            if (sKBitmap.IsEmpty)
            {
                return(bytes);
            }

            if (saveWidth < 1)
            {
                saveWidth = 1;
            }
            if (saveHeight < 1)
            {
                saveHeight = 1;
            }
            if (quality < 1)
            {
                quality = 1;
            }
            if (quality > 100)
            {
                quality = 100;
            }

            int    oW    = sKBitmap.Width;
            int    oH    = sKBitmap.Height;
            int    cutW  = saveWidth;
            int    cutH  = saveHeight;
            double ratio = 1;

            if (cutW > oW)
            {
                ratio = (double)oW / (double)cutW;
                cutH  = Convert.ToInt32((double)cutH * ratio);
                cutW  = oW;
                if (cutH > oH)
                {
                    ratio = (double)oH / (double)cutH;
                    cutW  = Convert.ToInt32((double)cutW * ratio);
                    cutH  = oH;
                }
            }
            else if (cutW < oW)
            {
                ratio = (double)oW / (double)cutW;
                cutH  = Convert.ToInt32(Convert.ToDouble(cutH) * ratio);
                cutW  = oW;
                if (cutH > oH)
                {
                    ratio = (double)oH / (double)cutH;
                    cutW  = Convert.ToInt32((double)cutW * ratio);
                    cutH  = oH;
                }
            }
            else
            {
                if (cutH > oH)
                {
                    ratio = (double)oH / (double)cutH;
                    cutW  = Convert.ToInt32((double)cutW * ratio);
                    cutH  = oH;
                }
            }
            int startX = oW > cutW ? (oW / 2 - cutW / 2) : (cutW / 2 - oW / 2);
            int startY = oH > cutH ? (oH / 2 - cutH / 2) : (cutH / 2 - oH / 2);

            var sKBitmap2 = new SkiaSharp.SKBitmap(saveWidth, saveHeight);
            var sKCanvas  = new SkiaSharp.SKCanvas(sKBitmap2);
            var sKPaint   = new SkiaSharp.SKPaint
            {
                FilterQuality = SkiaSharp.SKFilterQuality.Medium,
                IsAntialias   = true
            };

            sKCanvas.DrawBitmap(
                sKBitmap,
                new SkiaSharp.SKRect
            {
                Location = new SkiaSharp.SKPoint {
                    X = startX, Y = startY
                },
                Size = new SkiaSharp.SKSize {
                    Height = cutH, Width = cutW
                }
            },
                new SkiaSharp.SKRect
            {
                Location = new SkiaSharp.SKPoint {
                    X = 0, Y = 0
                },
                Size = new SkiaSharp.SKSize {
                    Height = saveHeight, Width = saveWidth
                }
            }, sKPaint);
            sKCanvas.Dispose();
            var sKImage2 = SkiaSharp.SKImage.FromBitmap(sKBitmap2);

            sKBitmap2.Dispose();
            var data = sKImage2.Encode(GetImageFormatByPath(path), quality);

            sKImage2.Dispose();
            bytes = data.ToArray();
            data.Dispose();

            return(bytes);
        }
Example #17
0
 protected virtual void Render(SkiaSharp.SKCanvas canvas, bool isClearCanvas)
 {
 }
Example #18
0
 protected virtual void OnRendering(SkiaSharp.SKCanvas canvas)
 {
 }
Example #19
0
 protected void InvalidateBitmap(SkiaSharp.SKCanvas canvas)
 {
 }
Example #20
0
 public static System.Windows.Rect MeasureTextBounds(this SkiaSharp.SKCanvas canvas, string text, System.Windows.Media.Color color, float fontSize = 14, double width = 4, SkiaSharp.SKTextAlign textAlign = 0)
 {
 }
Example #21
0
 public static void Draw(this SkiaSharp.SKPicture skPicture, SkiaSharp.SKColor background, float scaleX, float scaleY, SkiaSharp.SKCanvas skCanvas)
 {
     skCanvas.DrawColor(background);
     skCanvas.Save();
     skCanvas.Scale(scaleX, scaleY);
     skCanvas.DrawPicture(skPicture);
     skCanvas.Restore();
 }
 public abstract void DrawValues(Canvas c);
 public TetrisBlockDrawSkiaParameters(SkiaSharp.SKCanvas pG, SkiaSharp.SKRect pRegion, Nomino pGroupOwner, SettingsManager pSettings) : base(pGroupOwner, pSettings)
 {
     g      = pG;
     region = pRegion;
 }
 public abstract void DrawExtras(Canvas c);
Example #25
0
 public CanvasRenderingEventArgs(SkiaSharp.SKCanvas canvas)
 {
 }
Example #26
0
 public override void Draw(SkiaSharp.SKCanvas canvas, RectangleF dirtyRect)
 {
     _game.Render(new SKCanvasWrapper(canvas));
 }
Example #27
0
 public static void DrawLineThroughPoints(this SkiaSharp.SKCanvas canvas, System.Collections.Generic.IEnumerable <System.Windows.Point> points, SkiaSharp.SKPaint paint)
 {
 }
Example #28
0
        /// <summary>
        /// 生成二维码(320*320)
        /// </summary>
        /// <param name="text">文本内容</param>
        /// <param name="format">保存格式</param>
        /// <param name="logoImgae">Logo图片(缩放到真实二维码区域尺寸的1/6)</param>
        /// <param name="keepWhiteBorderPixelVal">白边处理(负值表示不做处理,最大值不超过真实二维码区域的1/10)</param>
        /// <returns></returns>
        public static byte[] QRCoder(string text, SkiaSharp.SKEncodedImageFormat format, byte[] logoImgae = null, int keepWhiteBorderPixelVal = -1)
        {
            byte[] reval        = null;
            int    width        = 320;
            int    height       = 320;
            var    qRCodeWriter = new ZXing.QrCode.QRCodeWriter();
            var    hints        = new Dictionary <ZXing.EncodeHintType, object>();

            hints.Add(ZXing.EncodeHintType.CHARACTER_SET, "utf-8");
            hints.Add(ZXing.EncodeHintType.QR_VERSION, 8);
            hints.Add(ZXing.EncodeHintType.ERROR_CORRECTION, ZXing.QrCode.Internal.ErrorCorrectionLevel.Q);
            var bitMatrix = qRCodeWriter.encode(text, ZXing.BarcodeFormat.QR_CODE, width, height, hints);
            var w         = bitMatrix.Width;
            var h         = bitMatrix.Height;
            var sKBitmap  = new SkiaSharp.SKBitmap(w, h);

            int blackStartPointX = 0;
            int blackStartPointY = 0;
            int blackEndPointX   = w;
            int blackEndPointY   = h;

            #region --绘制二维码(同时获取真实的二维码区域起绘点和结束点的坐标)--
            var sKCanvas     = new SkiaSharp.SKCanvas(sKBitmap);
            var sKColorBlack = SkiaSharp.SKColor.Parse("000000");
            var sKColorWihte = SkiaSharp.SKColor.Parse("ffffff");
            sKCanvas.Clear(sKColorWihte);
            bool blackStartPointIsNotWriteDown = true;
            for (var y = 0; y < h; y++)
            {
                for (var x = 0; x < w; x++)
                {
                    var flag = bitMatrix[x, y];
                    if (flag)
                    {
                        if (blackStartPointIsNotWriteDown)
                        {
                            blackStartPointX = x;
                            blackStartPointY = y;
                            blackStartPointIsNotWriteDown = false;
                        }
                        blackEndPointX = x;
                        blackEndPointY = y;
                        sKCanvas.DrawPoint(x, y, sKColorBlack);
                    }
                    else
                    {
                        //sKCanvas.DrawPoint(x, y, sKColorWihte);//不用绘制(背景是白色的)
                    }
                }
            }
            sKCanvas.Dispose();
            #endregion

            int qrcodeRealWidth  = blackEndPointX - blackStartPointX;
            int qrcodeRealHeight = blackEndPointY - blackStartPointY;

            #region -- 处理白边 --
            if (keepWhiteBorderPixelVal > -1)//指定了边框宽度
            {
                var borderMaxWidth = (int)Math.Floor((double)qrcodeRealWidth / 10);
                if (keepWhiteBorderPixelVal > borderMaxWidth)
                {
                    keepWhiteBorderPixelVal = borderMaxWidth;
                }
                var nQrcodeRealWidth  = width - keepWhiteBorderPixelVal - keepWhiteBorderPixelVal;
                var nQrcodeRealHeight = height - keepWhiteBorderPixelVal - keepWhiteBorderPixelVal;

                var sKBitmap2 = new SkiaSharp.SKBitmap(width, height);
                var sKCanvas2 = new SkiaSharp.SKCanvas(sKBitmap2);
                sKCanvas2.Clear(sKColorWihte);
                //二维码绘制到临时画布上时无需抗锯齿等处理(避免文件增大)
                sKCanvas2.DrawBitmap(
                    sKBitmap,
                    new SkiaSharp.SKRect
                {
                    Location = new SkiaSharp.SKPoint {
                        X = blackStartPointX, Y = blackStartPointY
                    },
                    Size = new SkiaSharp.SKSize {
                        Height = qrcodeRealHeight, Width = qrcodeRealWidth
                    }
                },
                    new SkiaSharp.SKRect
                {
                    Location = new SkiaSharp.SKPoint {
                        X = keepWhiteBorderPixelVal, Y = keepWhiteBorderPixelVal
                    },
                    Size = new SkiaSharp.SKSize {
                        Width = nQrcodeRealWidth, Height = nQrcodeRealHeight
                    }
                });

                blackStartPointX = keepWhiteBorderPixelVal;
                blackStartPointY = keepWhiteBorderPixelVal;
                qrcodeRealWidth  = nQrcodeRealWidth;
                qrcodeRealHeight = nQrcodeRealHeight;

                sKCanvas2.Dispose();
                sKBitmap.Dispose();
                sKBitmap = sKBitmap2;
            }
            #endregion

            #region -- 绘制LOGO --
            if (logoImgae != null && logoImgae.Length > 0)
            {
                SkiaSharp.SKBitmap sKBitmapLogo = SkiaSharp.SKBitmap.Decode(logoImgae);
                if (!sKBitmapLogo.IsEmpty)
                {
                    var sKPaint2 = new SkiaSharp.SKPaint
                    {
                        FilterQuality = SkiaSharp.SKFilterQuality.None,
                        IsAntialias   = true
                    };
                    var logoTargetMaxWidth  = (int)Math.Floor((double)qrcodeRealWidth / 6);
                    var logoTargetMaxHeight = (int)Math.Floor((double)qrcodeRealHeight / 6);
                    var qrcodeCenterX       = (int)Math.Floor((double)qrcodeRealWidth / 2);
                    var qrcodeCenterY       = (int)Math.Floor((double)qrcodeRealHeight / 2);
                    var logoResultWidth     = sKBitmapLogo.Width;
                    var logoResultHeight    = sKBitmapLogo.Height;
                    if (logoResultWidth > logoTargetMaxWidth)
                    {
                        var r = (double)logoTargetMaxWidth / logoResultWidth;
                        logoResultWidth  = logoTargetMaxWidth;
                        logoResultHeight = (int)Math.Floor(logoResultHeight * r);
                    }
                    if (logoResultHeight > logoTargetMaxHeight)
                    {
                        var r = (double)logoTargetMaxHeight / logoResultHeight;
                        logoResultHeight = logoTargetMaxHeight;
                        logoResultWidth  = (int)Math.Floor(logoResultWidth * r);
                    }
                    var pointX = qrcodeCenterX - (int)Math.Floor((double)logoResultWidth / 2) + blackStartPointX;
                    var pointY = qrcodeCenterY - (int)Math.Floor((double)logoResultHeight / 2) + blackStartPointY;

                    var sKCanvas3 = new SkiaSharp.SKCanvas(sKBitmap);
                    var sKPaint   = new SkiaSharp.SKPaint
                    {
                        FilterQuality = SkiaSharp.SKFilterQuality.Medium,
                        IsAntialias   = true
                    };
                    sKCanvas3.DrawBitmap(
                        sKBitmapLogo,
                        new SkiaSharp.SKRect
                    {
                        Location = new SkiaSharp.SKPoint {
                            X = 0, Y = 0
                        },
                        Size = new SkiaSharp.SKSize {
                            Height = sKBitmapLogo.Height, Width = sKBitmapLogo.Width
                        }
                    },
                        new SkiaSharp.SKRect
                    {
                        Location = new SkiaSharp.SKPoint {
                            X = pointX, Y = pointY
                        },
                        Size = new SkiaSharp.SKSize {
                            Height = logoResultHeight, Width = logoResultWidth
                        }
                    }, sKPaint);
                    sKCanvas3.Dispose();
                    sKPaint.Dispose();
                    sKBitmapLogo.Dispose();
                }
                else
                {
                    sKBitmapLogo.Dispose();
                }
            }
            #endregion

            SkiaSharp.SKImage sKImage = SkiaSharp.SKImage.FromBitmap(sKBitmap);
            sKBitmap.Dispose();
            var data = sKImage.Encode(format, 75);
            sKImage.Dispose();
            reval = data.ToArray();
            data.Dispose();

            return(reval);
        }
Example #29
0
 public static void DrawText(this SkiaSharp.SKCanvas canvas, string[] lines, System.Windows.Rect rect, System.Windows.Media.Color color, float fontSize = 14, double width = 4, double?lineSpacing = default, SkiaSharp.SKTextAlign textAlign = 0, bool clip = true)
 {
 }