gpt4 book ai didi

image - Xamarin 图像数据在流副本上无效

转载 作者:行者123 更新时间:2023-12-05 07:32:15 24 4
gpt4 key购买 nike

在第一种情况下,代码工作正常。在第二种情况下,我得到:

ImageLoaderSourceHandler: Image data was invalid: Xamarin.Forms.StreamImageSource

那么,案例 A(工作正常):

Stream stream = await DependencyService.Get<IPicturePicker>().GetGalleryStreamAsync();
image.Source = ImageSource.FromStream(() => stream);

案例 B(错误):

MemoryStream memoryStream = new MemoryStream();
Stream stream = await DependencyService.Get<IPicturePicker>().GetGalleryStreamAsync();
stream.CopyTo(memoryStream);
image.Source = ImageSource.FromStream(() => memoryStream);

请帮忙!

最佳答案

在最后一行试试这个

 Imgsrc= ImageSource.FromStream(() => new MemoryStream(memorystream));

关于image - Xamarin 图像数据在流副本上无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51332462/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com