1

I'm currently using the WriteableBitmapEx extension for my writeable Bitmap class. So far everything works now I'm doing this in a WinRT project. I run this code to merge the bitmaps together.

 Windows.Storage.Pickers.FileSavePicker save = new Windows.Storage.Pickers.FileSavePicker();
 save.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
 save.DefaultFileExtension = ".png";
 save.FileTypeChoices.Add("PNG", new string[] { ".png" });
 StorageFile filesave = await save.PickSaveFileAsync();
 IOutputStream ab = await filesave.OpenAsync(FileAccessMode.ReadWrite);

 if (ab != null)
 {
      //   await _inkManager.SaveAsync(ab);

      var imageUri = new Uri("http://i.imgur.com/rbiLg5Z.gif");
      var fullSizeBitmap = new Windows.UI.Xaml.Media.Imaging.BitmapImage(imageUri);
      // image.Source = fullSizeBitmap;

      var file = await WebFile.SaveAsync(imageUri);
      WriteableBitmap myTempImage = await new WriteableBitmap(1, 1).LoadAsync(file);

      // error!
      myImage.Blit(new Rect(0, 0, 20, 28), myTempImage, new Rect(0, 0, 20, 38));

Now on the line of myImage.Blit I get an unhandled exception for access violation. I really truly don't understand what's going on or what I'm doing wrong. So an help would be appreciated.

chue x
  • 18,573
  • 7
  • 56
  • 70
rubsnick
  • 61
  • 6

1 Answers1

2

Most likely either the size of the source or target WriteableBitmap is smaller than the rectangle you pass. Alternatively there might be a bug in one of the methods you are using. Verify the PixelWidth/PixelHeight of the bitmaps you are processing.

Filip Skakun
  • 31,624
  • 6
  • 74
  • 100
  • I verified this and they are the same Size. I then decided to use the same image by doing this code myImage.Blit(new Rect(0, 0, myImage.PixelHeight, myImage.PixelWidth), myImage, new Rect(0, 0, myImage.PixelHeight, myImage.PixelWidth)); I then had it give me the error once, then I ran it again in the same session/instance and it didn't give me the error instead another Exception saying key not found.... I'm at a loss there is something wrong with the image and the memory but I'm not sure. – rubsnick Nov 21 '13 at 13:41