1

I tried everything, but the WriteableBitmap class just doesn't have the .CopyPixels() method like it is said in the droumentation:https://msdn.microsoft.com/de-de/library/system.windows.media.imaging.writeablebitmap_methods(v=vs.110).aspx

Example of what Microsoft Visual Studio 2015 underlines red:

 writeableBitmap.CopyPixels(new Int32Rect(0, 0, 20, 10),pixels, 20 * 4, 0);
Fabian
  • 23
  • 1
  • 4
  • It works fine in my environment. Have you included a reference to PresentationCore. dll ? – Trifon Sep 15 '16 at 17:03
  • Now...Yes, and there was a second reason why it didn't work . I used "using Windows.UI.Xaml.Media.Imaging;" instead of "using System.Windows.Media.Imaging;". Thank you :) – Fabian Sep 15 '16 at 18:40

1 Answers1

2

According to your description, what you want is the WriteableBitmap class in UWP. However, the document you've referenced is the WriteableBitmap Class in .NET Framework, which is used in traditional desktop apps. For matching document, please see WriteableBitmap class.

And for the the WriteableBitmap class in UWP, we can use WriteableBitmap.PixelBuffer property to get the pixels from a WriteableBitmap like:

byte[] pixels = writeableBitmap.PixelBuffer.ToArray();

For more info, please see XAML images sample. Although this is a Windows 8.1 Store app, but it's the same in UWP apps.

Jay Zuo
  • 15,653
  • 2
  • 25
  • 49
  • I tried this solution but I get an error: `Value cannot be null.\r\nParameter name: source`. Maybe you have an idea of the issue http://stackoverflow.com/questions/39817619/converting-a-writeablebitmap-image-toarray-in-uwp – JTIM Oct 02 '16 at 15:09