转换BitmapImage [英] Converting a BitmapImage

查看:131
本文介绍了转换BitmapImage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个为我输出BitmapImage的DLL,但是我需要一个BitmapFrame.
我尝试使用BitmapFrame.Creat ...无济于事.

有关如何将System.Windows.Media.Imaging.BitmapImage转换为System.Windows.Media.Imaging.BitmapFrame的任何想法?

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!

推荐答案

根据Microsoft,您应该可以使用BmpBitmapDecoder (或选择的解码器).我已经测试过,并且有效:
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];


这篇关于转换BitmapImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆