Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug]How to convert StreamImageSource.Stream to image in Xamarin.Forms #7026

Closed
BalasubramaniSundaram opened this issue Jul 31, 2019 · 2 comments

Comments

@BalasubramaniSundaram
Copy link

I'm covert the image as stream and set to the Xamarin.Forms.Image.Source, In button click, am trying to access the same image, but in code behind am getting the image as StreamImagesSource from that I can't able to access to get the stream.

Assembly _assembly = this.GetType().Assembly;
Stream stream = _assembly.GetManifestResourceStream("DataGrithWithImagePdfExport.Resources.Jk.png");
ImageSource source = ImageSource.FromStream(() => stream);

///Added the image to the ImageSource property in Model
Persons.Add(new Person() { Name = "John Smith", Photo = source });
Please helps me to overcome this issue.
Thanks.

@BalasubramaniSundaram BalasubramaniSundaram added s/unverified New report that has yet to be verified t/bug 🐛 labels Jul 31, 2019
@pauldipietro pauldipietro added this to New in Triage Jul 31, 2019
@BalasubramaniSundaram BalasubramaniSundaram changed the title [Bug]How to get the path of the image from stream in Xamarin.Forms [Bug]How to convert StreamImageSource.Stream to image in Xamarin.Forms Aug 1, 2019
@jfversluis jfversluis added t/question and removed s/unverified New report that has yet to be verified t/bug 🐛 labels Aug 2, 2019
@StephaneDelcroix
Copy link
Member

what you're doing looks correct, but it's possible that your stream gets disposed.

I ran through our tests and samples, and we do this in some places

ImageSource.FromStream(() => typeof(App).Assembly.GetManifestResourceStream("Xamarin.Forms.Controls.coffee.png"))

so it should work

Triage automation moved this from New to Closed Aug 2, 2019
@BalasubramaniSundaram
Copy link
Author

BalasubramaniSundaram commented Aug 19, 2019

Hi @StephaneDelcroix ,
Thanks, We have already done this solution but it doesn't work in our case. In our case, we get the image source as a bit array from the database, so the image didn't physically present in the application. In that scenario, we couldn't able to use "Xamarin.Forms.Controls" it will through exception.
We have tried a different step to achieve a solution but everything ends up big stumbling with couldn't able to convert "ImageStream" to "ImageSource" at the back end, as we set the image source as a stream.
We expecting for a good solution to overcome this issue, thanks to advance.

@samhouts samhouts removed this from Closed in Triage Sep 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants