Pregunta

I'm trying to create a WriteableBitmap from an Image on my hard drive using WriteableBitmapEx. I copied the code from the official page after adding the nuget package:

WriteableBitmap writeableBmp = new WriteableBitmap(0, 0).FromResource("Data/flower2.png");

but I get the error

'System.Windows.Media.Imaging.WriteableBitmap' does not contain a constructor that takes 2 arguments

I have added the PresentationCore.dll as I was told here WriteableBitmapEx in console application? and also a using statement for System.Windows.Media.Imaging.

¿Fue útil?

Solución

The WriteableBitmapEx library provides a generic factory method for constructing writeable bitmaps, namely BitmapFactory.New. Use this portable method instead to generate your dummy writeable bitmap:

WriteableBitmap writeableBmp = BitmapFactory.New(0, 0).FromResource("Data/flower2.png");

The BitmapFactory class is in the System.Windows.Media.Imaging namespace (unless you are using the WinRT version of WriteableBitmapEx, where it is in the Windows.UI.Xaml.Media.Imaging namespace).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top