Load resource uri with Base64 image not work while using databinding
See original GitHub issueI 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.ImageLoaderTask
3+<RunAsync>d__108[TDecoderContainer,TImageContainer
,TImageView].MoveNext () [0x002f7] in C:\projects\ffimageloading\source\FFImageLoading.Common\Work\ImageLoaderTask.cs:523
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
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 typeImageSource
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
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