-1

System.Drawing.Imaging 命名空间中的PixelFormat枚举具有Format32bppArgbFormat8bppIndexed等成员,这些成员在调用其ToString方法时会显示。

您是否知道将 PixelFormat 值转换为更适合在图形程序中显示的字符串的内置方法或其他方法,例如24 BPP24bpp

4

1 回答 1

3

尝试类似我快速拼凑的这种扩展方法:

public static string ToFancyString(this PixelFormat format)
{
    switch (format)
    {
        case PixelFormat.Format16bppArgb1555:
            return "16bpp ARGB";
        case PixelFormat.Format16bppGrayScale:
            return "16bpp Gray";
        case PixelFormat.Format16bppRgb555:
            return "16bpp RGB";
        case PixelFormat.Format16bppRgb565:
            return "16bpp RGB";
        case PixelFormat.Format1bppIndexed:
            return "1bpp Indexed";
        case PixelFormat.Format24bppRgb:
            return "24bpp RGB";
        case PixelFormat.Format32bppArgb:
            return "32bpp ARGB";
        case PixelFormat.Format32bppPArgb:
            return "32bpp Premultiplied ARGB";
        case PixelFormat.Format32bppRgb:
            return "32bpp RGB";
        case PixelFormat.Format48bppRgb:
            return "48bpp RGB";
        case PixelFormat.Format4bppIndexed:
            return "4bpp Indexed";
        case PixelFormat.Format64bppArgb:
            return "64bpp ARGB";
        case PixelFormat.Format64bppPArgb:
            return "64bpp Premultiplied ARGB";
        case PixelFormat.Format8bppIndexed:
            return "8bpp Indexed";
        default:
            return format.ToString();
    }
}
于 2012-12-11T18:34:44.977 回答