获得System.Windows.Media.PixelFormats 的最佳方式是什么?相当于 System.Drawing.Imaging.PixelFormat 的值?
最佳答案
这是一种转换方式,所以让我们从这里开始,看看是否有人可以超越这个可怕的装置。它们相互映射得很好,所以编写 switch case 应该相当容易。
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();
}
关于wpf - 将 GDI+ PixelFormat 转换为 WPF PixelFormat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5106505/