0

I have a bitmap that is created in memory (using graphics drawing to add lines etc to it). I can save it no problem using

bmp.Save(@"Path");

I want to display it in my WPF window, the only example I have found which seems to do what I want is

Bitmap bmp = someClass.returnMap(); // returns a Bitmap which has been drawn
bmp.Save(@"Path"); //Just so I know the bitmap isn't null
ImageSourceConverter isc = new ImageSourceConverter();
image.Source = (ImageSource)isc.ConvertFrom(bmp); //I get a null refrence exception here

I have no idea why I am getting a null reference or why there is so much conflicting information when I try and Google this.

Edit Error message as requested

'An exception of type 'System.NullReferenceException' occurred in PresentationCore.dll but was not handled in user code

Additional information: Object reference not set to an instance of an object.

If there is a handler for this exception, the program may be safely continued.'

3
  • please show use the full error stack maybe we can find something in it Commented Dec 10, 2015 at 11:12
  • Added the error message Commented Dec 10, 2015 at 11:33
  • Looks like image is null. You can easily find that out by debugging your code. Commented Dec 10, 2015 at 15:04

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.