locked
Access Violation exception : WriteableBitmap.Convolute(WriteableBitmapExtensions.KernelGaussianBlur5x5

    Question

  • Hello i have a problem when run this code in mobile: I can´t catch exception ...

    (Information additional : attemped to read or write protected memory...)

    StorageFile imageFile = await FacebookService.LoadImageStorageFile(initDatas.PersonAccount.Facebook_Id__c, "photoProfileFB.jpg");
                    StorageFile imageFileDifunida = await FacebookService.LoadImageStorageFile(initDatas.PersonAccount.Facebook_Id__c, "ImagenDifufinada.jpg");
                  
                    if (imageFileDifunida == null)
                    {
                        if (imageFile != null)
                        {

                            WriteableBitmap Scenario4WriteableBitmap = new WriteableBitmap(390, 200);
                            // Set the source of the WriteableBitmap to the image stream
                            using (IRandomAccessStream fileStream = await imageFile.OpenAsync(Windows.Storage.FileAccessMode.Read))
                            {
                                try
                                {
                                    await Scenario4WriteableBitmap.SetSourceAsync(fileStream);
                                    Scenario4WriteableBitmap.Invalidate();
                                    isIsvalidate = true;
                                }
                                catch (TaskCanceledException)
                                {
                                    // The async action to set the WriteableBitmap's source may be canceled if the user clicks the button repeatedly
                             
                                }
                                catch (Exception)
                                {
                                    isError = true;
                                }
                            }
                            try
                            {
                              
                                    Scenario4WriteableBitmap.Invalidate();
      Scenario4WriteableBitmap = Scenario4WriteableBitmap.Convolute(WriteableBitmapExtensions.KernelGaussianBlur5x5); // Exception HERE!!!
                                    Scenario4WriteableBitmap = Scenario4WriteableBitmap.Convolute(WriteableBitmapExtensions.KernelGaussianBlur5x5);
                                    Scenario4WriteableBitmap = Scenario4WriteableBitmap.Convolute(WriteableBitmapExtensions.KernelGaussianBlur5x5);
                                    Scenario4WriteableBitmap = Scenario4WriteableBitmap.Convolute(WriteableBitmapExtensions.KernelGaussianBlur5x5);
                                    Scenario4WriteableBitmap = Scenario4WriteableBitmap.Convolute(WriteableBitmapExtensions.KernelGaussianBlur5x5);
                                    Scenario4WriteableBitmap = Scenario4WriteableBitmap.Convolute(WriteableBitmapExtensions.KernelGaussianBlur5x5);
                                    Scenario4WriteableBitmap = Scenario4WriteableBitmap.Convolute(WriteableBitmapExtensions.KernelGaussianBlur5x5);
                                    Scenario4WriteableBitmap = Scenario4WriteableBitmap.Crop(40, 40, 100, 100);
                                    Scenario4WriteableBitmap.Invalidate();
                                    await FacebookService.SaveWriteableBitmapAsJpeg(initDatas.PersonAccount.Facebook_Id__c, Scenario4WriteableBitmap, "ImagenDifufinada.jpg");
                                    ImagenFondoDifuminda = Scenario4WriteableBitmap;
                                
                            }
                            catch (Exception ex)
                            {


                            }

                        }

                                                                                      
    Sunday, February 8, 2015 5:09 PM

Answers

  • Sergio - WriteableBitmap.Convolute is not a standard function for Windows Store apps.  If you're getting an AV in that funciton, you'll need go to back to the place where you downloaded it from.  I assume it's this:

    http://writeablebitmapex.codeplex.com/

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, February 9, 2015 1:34 PM
    Moderator