Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Saving an image (signaturepad) in an android device

$
0
0

Hello,

I've an application that uses a signaturepad, with a button that when it is clicked, the image is saved in a ftp. Issue is that image saved is only like an icon 32x32 size, so... it is not the image.

I am thinking to save previously in the device, and after that, take the file and transfer using ftp.

I don't know how to save the image (signaturepad) in the device.

I am using vc2017 c# and xamarin.

At the moment, I have the following code (wrong code):

private async void onSaveAsync(object sender, EventArgs e)
{ // recuperar imagen

        Stream x;
        byte[] buffer;
        Stream reqStream;

        FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create("ftp://alfabeta");

         try
           {

            x = await signature.GetImageStreamAsync(SignatureImageFormat.Png);

            // this is actually memory-stream so convertible to it
            var mstream = (MemoryStream)x;
            //Unfortunately above mstream is not valid until you take it as byte array
            mstream = new MemoryStream(mstream.ToArray());

            //long longitud = mstream.Length;

            request.Method = WebRequestMethods.Ftp.UploadFile;
            request.Credentials = new NetworkCredential("soporte-siga@sgsst-svial.co", "fabio1siga+");
            request.UsePassive = true;
            request.UseBinary = true;
            request.KeepAlive = true;
            buffer = BitConverter.GetBytes(mstream.Length);
            mstream.Read(buffer, 0, buffer.Length);
            mstream.Close();


            reqStream = request.GetRequestStream();
            reqStream.Write(buffer, 0, buffer.Length);
            reqStream.Flush();
            reqStream.Close();

        }
        catch (DirectoryNotFoundException dirEx)
           {
               // Let the user know that the directory did not exist.
               Console.WriteLine("Directory not found: " + dirEx.Message);
           }
    }

Any ideas?

Thank you


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>