Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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!
Posted

1 solution

According to Microsoft you should be able to use BmpBitmapDecoder (or the decoder of choice). I've tested, and it worked:
C#
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];
 
Share this answer
 
v3
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900