使用手指画法使用位图图像保存SkiaSharp画布

问题描述

我试图在位图图像上绘制,然后需要保存更新的图形

到目前为止,我可以在画布上获取图像,也可以在位图图像上绘图,但是问题是当我导出流时,我看不到我的绘图,我只能得到位图流

这是到目前为止我实现的代码

全局变量

 private SKBitmap sKBitmap;

建设者

                using (Stream stream = ImageDataStream)
                {
                    sKBitmap = SKBitmap.Decode(stream);
                }

InvalidatedSurface

 private void OnCanvasViewPaintSurface(object sender,SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs args)
    {
        globalSurface = args.Surface;
        SKCanvas canvas = globalSurface.Canvas;
        SKImageInfo info = args.Info;
        canvas.Clear();
        if (sKBitmap != null)
        {
            canvas.DrawBitmap(sKBitmap,info.Rect,BitmapStretch.Uniform);
        }

        foreach (SKPath path in completedpaths)
        {
            canvas.DrawPath(path,paint);
        }

        foreach (SKPath path in inProgresspaths.Values)
        {
            canvas.DrawPath(path,paint);
        }
    }

画布保存代码

using (SKImage image = SKImage.FromBitmap(sKBitmap))
            {
                SKData data = image.Encode();
                var imageBytes = data.ToArray();
            }

在保存的同时我得到的是原始图像,而不是用绘图更新的图像,不确定我在做什么错

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)