GetStream returns very small image after crop

Hi,

Tested in Android(6.0), the GetStream method returns very small image when I execute the following commands:
1. Crop
2. Save
3. GetStream

iOS is working well.

Thanks,
Clyde

5 Replies

MP Michael Prabhu M Syncfusion Team August 13, 2018 06:58 AM UTC

Hi Clyde, 
 
Greetings from Syncfusion, we are able to reproduce this issue in Android and this is due to handling of memory management with respect to the RAM size. We have reduced the size on the image with respect to the memory available in the application for different Android devices, we have already logged an improvement task on this scenario and we working on this, the fix for this will be available in our Volume 3 2018, which is scheduled to be rolled out at the end of September 2018. We appreciate your patience until then. 
 
Thanks, 
Michael 




MG Marian Grzesik September 6, 2018 12:09 PM UTC

Hi, 
I have the same problem. I've solved this so:

public void Edit_Clicked(object sender, EventArgs e)
        {
            ImageEditor.Crop();
            EditBar.IsVisible = false;
            ImageEditor.Save();
            ImageEditor.ImageSaved += ImageEditor_ImageSaved;
        }

private async void ImageEditor_ImageSaved(object sender, ImageSavedEventArgs args)
        {
            
                await Task.Delay(1000);
                Device.BeginInvokeOnMainThread(async () =>
                {
                    var stream = await ImageEditor.GetStream();
                    //here is the right stream
                });
            }
        }

I've noticed that, without the delay, you get an Image with a text "Saving". I think it is a bug. On iOS it is necessary to use Device.BeginInvokeOnMainThread, because the app crash. It is strange, because after await we should be back on the IU thread.
I suggest also to change the interface to the Save function to Task<Stream> Save(). It'd be easier to manage this situation.

Thanks Marian



MP Michael Prabhu M Syncfusion Team September 10, 2018 06:49 AM UTC

Hi Marian, 
 
Thanks for the update, please find the response for your queries. 
 
Query 1: I've noticed that, without the delay, you get an Image with a text "Saving". 
 
In case of high resolution images, it will take time to save the images. So that we are showing this text. But in case of iOS platform, it won't take much time to save. So, on Android we will just show a text "Saving" before the image is saved in to device.  
 
Query 2: On iOS it is necessary to use Device.BeginInvokeOnMainThread, because the app crash.  
 
If you want to get the stream of the image, then you can get the stream from Image saving event args instead of GetStream method. So, can you please change the code as like below. 
editor.ImageSaving += (sender, args) =>
{
   args.Cancel = true; // This will avoid to save image in gallery also saving text will not show
   var stream = args.Stream; // Here is the original stream
};
editor.Save(); 
 
  
Thanks, 
Michael 



MG Marian Grzesik September 14, 2018 05:56 AM UTC

Hi Michael,

Query 1: I've noticed that, without the delay, you get an Image with a text "Saving". 

It is strange, that the control mix the text "Saving" with the image. I expected, that the info text would be displayed on an overlay and don't change my image. I hope that at the end my image is only cropped.

Query 2: On iOS it is necessary to use Device.BeginInvokeOnMainThread, because the app crash.  

I had tried the code you presented, but it doesn't work! I got only a small stream with a white or black content. I hope, that your code works in the next version.

editor.ImageSaving += (sender, args) =>
{
   args.Cancel = true; // This will avoid to save image in gallery also saving text will not show
   var stream = args.Stream; // Here is the original stream
};
editor.Save(); 

There is one another bug in the code. I transfer a MemoryStream to the control. I don't want, that the image will be saved to the Picture Library. But it does! I'm getting always some strange  black or white rectangle as a picture in the library!!!

Thanks 
Marian




MP Michael Prabhu M Syncfusion Team September 14, 2018 09:47 AM UTC

Hi Marian, 
 
Queries 1 & 2: Control mix the text "Saving" with the image;  I'm getting always some strange  black or white rectangle as a picture in the library! 
 
We are not able to reproduce the mentioned issues on our side and we have created a sample as per your requirement. Please test this and let us know if you are still facing this issue.  
 
 
The following steps we have done in the above sample. 
 
  1. Loaded ImageEditor control in left side and Image Control in right side
  2. When we crop the image, getting the stream from ImageSaving event and resulted image will be loaded in ImageControl
Thanks, 
Michael 
 
 


Loader.
Up arrow icon