How to load an image to sfImageEditor with the Build Action set to AndroidResource?

Hi, 

I have a few images in my application and I load them using ImageSource.FromFile() - well, cause it is faster than FromResource()-  and when each of the images is tapped, the image must load into SfImageEditor so that the user will be able to zoom In/Out the image, but the problem is when I started using ImageSource.FromFile() instead of  FromResource(), the image won't load to SfImageEditor! Is there a way to be able to load the images to SfImageEditor that their build action has been set to AndroidResource?

Edit:
This code doesn't work:
    public partial class SfImageEditorPage : ContentPage
    {
        public SfImageEditorPage(string file)
        {
            InitializeComponent();
            editor.Source = ImageSource.FromFile(file);     
        }
     }

Thanks in advance,
Reihaneh

7 Replies

MP Michael Prabhu M Syncfusion Team October 23, 2018 10:10 AM UTC

Hi Reihaneh, 
 
Greetings from Syncfusion.  
 
Query:  Is there a way to be able to load the images to SfImageEditor that their build action has been set to AndroidResource. 
 
We have validated your query and we found that image is not loaded from drawable resource in image editor android. But when we give absolute path of file then its working correctly as like below code snippet. 
 
editor.Source = ImageSource.FromFile("image.png"); // Not working
editor.Source = ImageSource.FromFile("/storage/0/emulated/Pictures/image.png"); // Working
 
 
So, we have created workaround sample to copy the drawable image file to gallery and then loading image from file path. Please find the sample from below link 
 
 
In this sample, we have done following things 
 
1. Created Dependency service method GetPath() to copy image from drawable resource to gallery.   
 
// pass image name as argument to GetPath method.
var path = DependencyService.Get < IFileHelperInterface().GetPath("image.png"); 
editor.Source = ImageSource.FromFile(path); 
 
We request you to try the above sample and let us know if you have any concern.  
 
Also, we have logged bug report to read the image from drawable folder and this will be included in 2018 Volume 3 SP1 release which is expected to be released on end of October 2018. 
 
Thanks, 
Michael 
 



RK Reihaneh Khaksaran October 23, 2018 04:53 PM UTC

Hi Michael ,

Thank you for your time and the sample you provided, I checked it out, and problem is that I don't want the image to be saved in gallery, this is not proper for my app, I just want it to load from drawable folder, no need to save it in the gallery, so I guess I'm gonna have to wait for the update to be released, and I hope it will resolve my issue.

Thanks again,
Reihaneh


MP Michael Prabhu M Syncfusion Team October 24, 2018 06:52 AM UTC

Hi Reihaneh, 
 
Thanks for the update, as promised earlier the support to read the image from drawable folder will be available in our 2018 Volume 3 SP1 release which is expected to be rolled out at the end of October 2018. We appreciate your patience until then. 
 
Regards, 
Michael 




RK Reihaneh Khaksaran October 31, 2018 03:13 PM UTC

Hi,

I have installed the update(version 16.3.029), but the problem still exists :( 


MP Michael Prabhu M Syncfusion Team November 1, 2018 06:41 AM UTC

Hi Reihaneh, 
 
We have fixed issue, "unable to load Image from drawable in android" in our latest update (16.3.0.29). we are unable to reproduce this issue in our latest update (16.3.0.29). So, we have created sample for this and please find the sample from below link. 
 
 
We suspect that previous NuGet is not cleared from cache properly. So, can you please follow the below steps to clear the NuGet cache,  
 
For Windows:  
 
Follow the below link to clear cache, 
  
 
 
For Mac : 
 
Can you please check and remove in your mac if there is any package in the following location?  
 
• ~/.local/share/NuGet/Cache  
• ~/.nuget/package 
 
Thanks, 
Michael 




RK Reihaneh Khaksaran November 4, 2018 01:53 PM UTC

Hi,

Thank you, there was a problem with my code, and now it's resolved and working fine.
Thank you so much for your great support.

Best regards,
Reihaneh


MV Mohana V Syncfusion Team November 5, 2018 05:57 AM UTC

Hi Reihaneh,

You are welcome. Please get back us, if you require any further assistance.

Regards,
Mohana V

Loader.
Up arrow icon