【问题标题】:SignaturePad Xamarin Forms PCL unable to capture ImageSignaturePad Xamarin Forms PCL 无法捕获图像
【发布时间】:2017-04-04 18:42:03
【问题描述】:

我正在为 PCL 使用 SignaturePad Nuget。

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

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

【问题讨论】:

  • 请不要将代码发布为图片!
  • 问题只是关于一个函数。所以最好在这种情况下粘贴图像。如果您知道答案,请回复。谢谢。
  • 不,不是。搜索引擎无法索引图像中的代码,屏幕阅读器无法阅读它们,因此积极劝阻。

标签: xamarin xamarin.forms multiplatform signaturepad


【解决方案1】:

这是我经过 2 周的研究后发现的。

这是在 C# 中将签名保存到 Android 手机上的 png 文件的代码。

 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


    }

玩得开心!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-26
    • 1970-01-01
    • 2018-08-11
    • 1970-01-01
    相关资源
    最近更新 更多