1

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

JayDev
  • 1,340
  • 2
  • 13
  • 21
Jacek Grzelaczyk
  • 783
  • 2
  • 9
  • 21

2 Answers2

1

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.

meneses.pt
  • 2,588
  • 3
  • 27
  • 38
  • Yes, but when I don't set PixelHight and PixelWidth on chooser(thats means, dont initial crop/resize image inside PhotoChooserTask) then everything is ok. I am ok with this that I can't set such big photo, but user can do everything, so how can I dispose PhotoChooserTask to let user choose another one? Because if PhotoChooserTask crush user can't use again PhotoChooserTask until he restart my Application. – Jacek Grzelaczyk Jan 21 '15 at 07:57
1

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.

aman shivhare
  • 334
  • 2
  • 13