SignaturePad Xamarin表单PCL无法捕获图像

时间:2017-04-04 18:42:03

标签: xamarin xamarin.forms multiplatform signaturepad

我正在使用SignaturePad Nuget for PCL。

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

任何想法都会受到赞赏..谢谢。

enter image description here

1 个答案:

答案 0 :(得分: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


    }

玩得开心!