0

下载 xamarin.signaturePad 示例后,我只想将图像从签名板获取到内存流并显示在我的 imageview 上。这是我的代码,它在 iOS 上运行良好,但在 android 上显示空流

var image = await padView.GetImageStreamAsync(SignatureImageFormat.Png);
var stream = new MemoryStream();
image.CopyToAsync(stream);
var imageByteArray= stream.ToArray();
img_result.Source = ImageSource.FromStream(() => newMemoryStream(imageByteArray));
4

1 回答 1

1

只需将您的图像流转换为内存流。它应该是有效的

var imageStream = await padView.GetImageStreamAsync(SignatureImageFormat.Png);

// this is actually memory-stream so convertible to it
var mstream = (MemoryStream)imageStream;

//Unfortunately above mstream is not valid until you take it as byte array
mstream = new MemoryStream(mstream.ToArray());

//Now you can
img_result.Source = ImageSource.FromStream(()=>mstream);
于 2017-04-05T12:03:40.133 回答