Click here to Skip to main content
14,212,594 members
Rate this:
Please Sign up or sign in to vote.
Hi All,

I have a DLL which outputs a BitmapImage for me, however i need a BitmapFrame.
I've tried to use BitmapFrame.Creat... to no avail.

Any ideas on how to convert a System.Windows.Media.Imaging.BitmapImage to System.Windows.Media.Imaging.BitmapFrame?

Thanks in advance!

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

According to Microsoft you should be able to use BmpBitmapDecoder (or the decoder of choice). I've tested, and it worked:
Stream bmpStream = 
  new System.IO.FileStream("smiley.bmp", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
BmpBitmapDecoder bmpDecoder = 
  new BmpBitmapDecoder(bmpStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapFrame bmpFrame = bmpDecoder.Frames[0];
MitchG92_24 7-Sep-12 3:50am
Thanks Gjersøe! worked perfectly!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Cookies | Terms of Service
Web01 | 2.8.190619.2 | Last Updated 6 Sep 2012
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100