1
votes

When I want to pick photo from my library, and initially do something with this photo I want to crop it and resize to 300x300. Everything is OK, until I choose a big photo.

When I pick a big image (10000x6000) PhotoChooserTask does nothing (from the user's point of view), PhotoChooserTask just crashes (not the application). Then when I try picking another one I get "Not allowed to call Show() multiple times before an invocation returns" exception.

It seems PhotoChooserTask still has the previous object inside, and I don't know how to dispose or clear PhotoChooserTask.

PS. without setting

chooser.PixelHeight = 300;
chooser.PixelWidth = 300;

Photo will set, and everything is ok.

PS2.

Samsung ATIV S does not have a problem. Only nokia 1320 ,520 and 530

PhotoChooserTask chooser = new PhotoChooserTask();

try
{
    chooser.ShowCamera = true;
    chooser.PixelHeight = 300;
    chooser.PixelWidth = 300;

    chooser.Completed += (s, result) =>
    {
        if (result.Error != null){ return; }
        if (result.ChosenPhoto != null)
        {
           var bitmap = new BitmapImage();
           bitmap.SetSource(result.ChosenPhoto);
           Service.uploadPhoto(receiver, (ImageSource)bitmap);
        }
    };
    chooser.Show();
 }
 catch (Exception ex)
 {
     MessageBox.Show(ex.Message);
 }

When the photo is big and height is set the debugger doesn't enters inside chooser.Completed

2

2 Answers

1
votes

The image size is probably the problem.

An image of 10000x6000 will take approximately 240MB in memory itself (10000 * 6000 * 4 bytes per pixel). That ammount of memory is probably causing the app using the PhotoChooserTask to crash and not to return anything to your app.

1
votes

A possible solution is to first save the chosen photo into a jpeg of lower quality or in the same resolution but compressing it using High Compression methods like SavePng() method in Cimbalino Phone Toolkit and then crop the Image.

I use it to convert 240mb Image to 8mb then Apply the Effects on it.