2017-04-05 90 views
1

下載xamarin.signaturePad示例後,我只想從簽名板獲取圖像到內存流並顯示在我的imageview上。這裏是我的代碼和iOS及其工作正常,但在Android上的顯示空流以xamarin格式從signaturepad獲取圖像?

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)); 

回答

2

就投你的ImageStream到的MemoryStream。它應該是有效的

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);