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

Created Unassigned: FromStream broken for Wpf [21778]

$
0
0
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 seems to indicate the extension method uses a BitmapImage internally in an incorrect way, BeginInit and EndInit are probably missing

Viewing all articles
Browse latest Browse all 360

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>