Wpf – Convert ImageSource to BitmapImage – WPF

bitmapimagewpf

I'm using a class library that generates a large ImageSource, > 3000×3750 pixels. I would like to convert this ImageSource to BitmapImage so that I can take advantage of DecodePixelWidth or DecodePixelHeight instead of resizing it everytime this image is generated.

I need to display this image for the user first, and most of the users have a screen resolution of 1024×768, I'm binding this ImageSource to an Image control for this, but it can be noticed how "heavy" it is.

How can I do this? Or what is the best solution for this case?

thanks!

Best Solution

I know it's a old post, but try doing:

myBitmapImage = myImageSource as BitmapImage;

That works well.

Related Question