开发者

Converting GDI+ PixelFormat to WPF PixelFormat

开发者 https://www.devze.com 2023-02-13 09:23 出处:网络
What is the best way to get the System.Windows.Media.PixelFormats value equivalent to a Syst开发者_开发知识库em.Drawing.Imaging.PixelFormat ?This is a way of converting, so lets start here and see if

What is the best way to get the System.Windows.Media.PixelFormats value equivalent to a Syst开发者_开发知识库em.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();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消