0

I am using SignaturePad Nuget for PCL.

How do i convert this System.IO.Stream into an Image?

Any idea would be appreciated.. Thank you.

enter image description here

DEV
  • 949
  • 1
  • 9
  • 29
  • 1
    please DO NOT post code as images! – Jason Apr 04 '17 at 18:44
  • The question is just about a single function. So it good to paste the image in this scenario. Please respond if you know the answer. Thank you. – DEV Apr 04 '17 at 18:45
  • no, it is not. Search engines can't index the code in the image, screen readers can't read them, and SO actively discourages it. – Jason Apr 04 '17 at 18:51

1 Answers1

2

Here's what I found after 2 weeks of research about this.

This is the code in c# to save an signature to a png file on android phone.

 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


    }

have fun !