I can successfully load the next Bitmap like this and display it in the Image control on the view.
var bitmapImage = new BitmapImage { UriSource = new Uri("../Images/Test.JPG", UriKind.Relative) };
However, as soon as I add this line to create a WriteableBitmap from a bitmap,
var w = new WriteableBitmap(bitmapImage);
I get a runtime error in the line above: "The reference to the object is not installed in the object instance."
It seems that the creation of BitmapImage is delayed, maybe? How to fix it?
Update:
Now I'm trying to do this, but openImage seems to never get it. (without even trying to make it synchronous, it still doesn't work) What is wrong here?
var image = new BitmapImage(); image.ImageOpened += (sender, args) => resetEventBitmap.Set(); image.ImageFailed += (o, eventArgs) => { resetEventBitmap.Set(); throw eventArgs.ErrorException; }; image.CreateOptions = BitmapCreateOptions.IgnoreImageCache; image.UriSource = uri; resetEventBitmap.WaitOne();
Thanks,
Houman
source share