Quantcast
Channel: WriteableBitmapEx
Viewing all articles
Browse latest Browse all 360

Edited Issue: FromStream broken for Wpf [21778]

$
0
0
see also [this stackoverflow question](http://stackoverflow.com/questions/29079938/weird-writeablebitmap-fromstream-issue) for the bugfix.

I am desperately trying to load a WriteableBitmap with the FromStream extension method.

The code below throws a System.InvalidOperationException at the FromStream() call with the following information:

__ BitmapImage has not been initialized. Call the BeginInit method, set the appropriate properties, and then call the EndInit method.__

I verified that the image exists and it's build action is set to Resource. The image is valid (I loaded it into a BitmapImage) and the stream has the correct length.

var sri = Application.GetResourceStream(new Uri("dummy.jpg", UriKind.RelativeOrAbsolute));
if (sri != null)
{
using (var stream = sri.Stream)
{
// creates the bitmap, part of the writeablebitmapextensions on WPF
var wb = BitmapFactory.New(1, 1);
wb.FromStream(stream); // <--- Exception
}
}

The error indicates the extension method uses a BitmapImage internally in an incorrect way, BeginInit and EndInit are missing
Comments: ** Comment from web user: teichgraf **

Thanks for raising this. This was just fixed in the latest source code and will be part of the next release. If you need it now, just get latest source code and rebuild the lib locally or take the #if WPF part of the FromStream method into your code.


Viewing all articles
Browse latest Browse all 360

Trending Articles