2012-12-11 28 views
-1

從System.Drawing.Imaging命名空間的PixelFormat枚舉有像Format32bppArgb構件Format8bppIndexed,即在調用它的的ToString方法時顯示。一個更好PixelFormat.ToString輸出

你知道的PixelFormat值轉換爲更適合在圖形程序的顯示字符串內置或其他方法,如24 BPP24 bpp的

+2

我不知道任何現有的功能,但隨後的enumration不包含非常多的值。我不會爲此煩惱,只是自己寫。 –

+0

我正在尋找PixelFormat值的某些「標準」字符串列表,用戶在圖形程序中使用這些列表,這就是我問這個問題的原因。 – Jamrelian

回答

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(); 
    } 
}