首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SignaturePad Xamarin Forms PCL无法捕获图像

SignaturePad Xamarin Forms PCL无法捕获图像
EN

Stack Overflow用户
提问于 2017-04-05 02:42:03
回答 1查看 229关注 0票数 0

我正在使用PCL的SignaturePad Nuget。

如何将此System.IO.Stream转换为图像?

任何想法都将不胜感激。谢谢。

EN

回答 1

Stack Overflow用户

发布于 2017-09-23 05:21:39

这是我对此进行了两周的研究后发现的。

这是在安卓手机上将签名保存到png文件的c#代码。

代码语言:javascript
复制
 async void Enregistrer(object sender, EventArgs e)
    {


        // This is the code to get the image (as a stream)
        var img = padView.GetImage(Acr.XamForms.SignaturePad.ImageFormatType.Png); // This returns the Bitmap from SignaturePad.

        img.Seek(0,0); // This is to have the current position in the stream

        // create a new file stream for writing
        FileStream fs = new FileStream(Android.OS.Environment.ExternalStorageDirectory + "/imagefilename.png", FileMode.Create,FileAccess.Write); // create a new file stream for writing

        await img.CopyToAsync(fs); // have the image stream to disk

        fs.Close(); // close the filestream

        img.Dispose(); // clear the ressourse used by the stream


    }

祝你玩得开心!

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43215170

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档