question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Load resource uri with Base64 image not work while using databinding

See original GitHub issue

I have an image with base64 code (attached), using data:image/png;base64,[BASE64ENCODEDFILE] format to show, that work only while set directly in xaml but not work with data binding.

at FFImageLoading.DataResolvers.ResourceDataResolver.Resolve (System.String identifier, FFImageLoading.Work.TaskParameter parameters, System.Threading.CancellationToken token) [0x0005b] in C:\projects\ffimageloading\source\FFImageLoading.Droid\DataResolvers\ResourceDataResolver.cs:29 at FFImageLoading.DataResolvers.WrappedDataResolver+<Resolve>d__2.MoveNext () [0x00020] in C:\projects\ffimageloading\source\FFImageLoading.Common\DataResolvers\WrappedDataResolver.cs:22 — End of stack trace from previous location where exception was thrown — at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at FFImageLoading.Work.ImageLoaderTask3+<RunAsync>d__108[TDecoderContainer,TImageContainer ,TImageView].MoveNext () [0x002f7] in C:\projects\ffimageloading\source\FFImageLoading.Common\Work\ImageLoaderTask.cs:523

base64_image.txt

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
AndreSlimcommented, Nov 5, 2020

I had the same problem with images that were too large in base64, the solution for me was to remove the prefix data:image/jpg;base64, and set the Binding of type ImageSource

Fragment of my XAML code <ffimageloading:CachedImage Aspect="AspectFill" FadeAnimationEnabled="True" Source="{Binding Image}" />

Fragment of my C # code in ViewModel (MVVM pattern) Regex regex = new Regex(@"^[\w/\:.-]+;base64,"); imageBase64 = regex.Replace(imageBase64, string.Empty); Image = ImageSource.FromStream(() => new MemoryStream(Convert.FromBase64String(imageBase64)));

I hope it helps someone

1reaction
Mirinaelcommented, Nov 20, 2018

Hi, I think I’m having the same issue. If I use a very small base64 encoded image (~ <50ko), using a binding on the base64 string in xaml is working. However, with a bigger image, it raises an Image loading failed.

I didn’t try in cs instead of xaml tho. On my way. 😃 Edit : It works with _teasingImage.Source = new DataUrlImageSource(article.TeasingImage);

Here’s the stack trace : stack_trace.txt

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Not able to load base64 image
when i try to load ng-src value ( i.e data-ng-src="data:image/jpg;base64,base64 string value), it says that this site can't be reached. Is there ...
Read more >
Displaying images in SAPUI5 received from the Northwind ...
All we need to do is getting the Base64 encoded file content and trimming the first 104 bytes. Then we can set the...
Read more >
PictureBox Report Item at a Glance - Documentation - Telerik
Learn more about the Telerik Reporting PictureBox, how to set its value, bind it to binary images, expressions, URIs, base64, and SVG, and...
Read more >
Probably Don't Base64 SVG
But yeah, base64 is probably not always a good idea but svg can contain unsafe characters (remember, vector image can contain bitmap parts…)....
Read more >
Xamarin imagesource fromfile. Alternatively, embedded ...
svg Then I have the Images bound in my 3. When changing the load to an image in the Resource folder (Resizetizer generated),...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found