简体   繁体   English

为什么我无法从Xamarin形式的流中获取图像?

[英]Why am I unable to obtain an image from the stream in xamarin forms?

var image = await PicturePicker.PickImage(); 
 Image img = ImageSource.FromStream(image);

My code is as shown above. 我的代码如上所示。 image is a stream returned from the picture picker and i fed it to the FromStream function in xamarin forms but it thorws me the following error Argument type 'System.IO.Stream'is not assignable to parameter type System.Func 图像是从图片选择器返回的流,我将其馈送到xamarin形式的FromStream函数中,但它使我感到以下错误参数类型'System.IO.Stream'不能分配给参数类型System.Func

Any kind soul able to help me out with this? 有什么好心的人可以帮我这个忙吗?

I think instead of Image img. 我认为不是Image img。 You should use ImageSource img 您应该使用ImageSource img

public ImageSource Imgsrc;

and try this code 并尝试此代码

 Imgsrc = ImageSource.FromStream(() =>
                        {

                            return image;
                        });

Actually this is how I do to load the images to my ViewModel.Hope it helps 其实这就是我将图像加载到ViewModel的方法。希望对您有所帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Xamarin形成图像流 - Xamarin Forms Image to Stream 我想使用XLABS从Xamarin Forms中的流中获取图像数据 - I want to get the image data from a stream in Xamarin Forms using XLABS 为什么即使从服务器端成功验证后,我也无法获得HttpResposnseMessage? - Why am i unable to obtain HttpResposnseMessage even after successful validation from serverside? 如何从Xamarin.Forms中的流获取图像的路径 - How to get the path of the image from stream in Xamarin.Forms 升级到Xamarin Forms 2.0后,为什么会出现此错误? - Why am I getting this error after upgrading to Xamarin Forms 2.0? 为什么我没有从我的 BLE 设备发送到我的 xamarin 表单应用程序的字节 [] 中获得正确的值? - Why am I not getting the correct value from my byte [] that is being sent by my BLE-device to my xamarin forms app? 我正在尝试编写一个 xamarin.forms 应用程序来简单地拍照并保存图像, - I am trying to write a xamarin forms application to simply take a photo and save the image, 在Xamarin.Forms中订阅事件时,为什么只能在iOS上收到NullReferenceException? - Why am I getting a NullReferenceException when subscribing to event in Xamarin.Forms, but only on iOS? 在 Xamarin.Forms 中获取图像或 ImageSource 的字节 [] / 流? - Getting the bytes[] / stream of an Image or ImageSource in Xamarin.Forms? 如何在 xamarin.forms 中将流转换为位图以调整图像对比度 - How to convert stream to bitmap in xamarin.forms to adjust image contrast
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM