本文介绍了将GDI + PixelFormat转换为WPF PixelFormat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
获取系统的最佳方法是什么. Windows.Media.PixelFormats 值等于 System.Drawing.Imaging.PixelFormat 吗?
推荐答案
这是一种转换方式,所以让我们从这里开始,看看是否有人可以顶这个可怕的东西.它们相互之间的映射很好,因此编写切换用例应该相当容易.
This is a way of converting, so lets start here and see if someone can top this horrendeous contraption. They map well to eachother, so writing the switch cases should be fairly easy.
private static System.Windows.Media.PixelFormat ConvertPixelFormat(System.Drawing.Imaging.PixelFormat sourceFormat)
{
switch (sourceFormat)
{
case System.Drawing.Imaging.PixelFormat.Format24bppRgb:
return PixelFormats.Bgr24;
case System.Drawing.Imaging.PixelFormat.Format32bppArgb:
return PixelFormats.Bgra32;
case System.Drawing.Imaging.PixelFormat.Format32bppRgb:
return PixelFormats.Bgr32;
// .. as many as you need...
}
return new System.Windows.Media.PixelFormat();
}
这篇关于将GDI + PixelFormat转换为WPF PixelFormat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!