0

In .NET one way to check the bitdepth of a Bitmap image is using the Bitmap class like so:

switch (bitmap.PixelFormat) {
                case System.Drawing.Imaging.PixelFormat.Format1bppIndexed: return 1;
                case System.Drawing.Imaging.PixelFormat.Format4bppIndexed: return 4;
                case System.Drawing.Imaging.PixelFormat.Format8bppIndexed: return 8;
                case System.Drawing.Imaging.PixelFormat.Format16bppArgb1555:  
                case System.Drawing.Imaging.PixelFormat.Format16bppGrayScale:
                case System.Drawing.Imaging.PixelFormat.Format16bppRgb555:
                case System.Drawing.Imaging.PixelFormat.Format16bppRgb565: return 16;
                case System.Drawing.Imaging.PixelFormat.Format24bppRgb: return 24;
                case System.Drawing.Imaging.PixelFormat.Format32bppArgb:
                case System.Drawing.Imaging.PixelFormat.Format32bppPArgb:
                case System.Drawing.Imaging.PixelFormat.Format32bppRgb: return 32;
                case System.Drawing.Imaging.PixelFormat.Format48bppRgb: return 48;
                case System.Drawing.Imaging.PixelFormat.Format64bppArgb:
                case System.Drawing.Imaging.PixelFormat.Format64bppPArgb: return 64;
}

I am trying to write an equivalent function targeting Mono for Android (xamarin project) that returns me the bitdepth of a Bitmap file but the Bitmap class in the Adroid.Graphics namespace, is a lot less helpful - or perhaps just too unfamilar to me. Can anyone help?

Darrell
  • 1,905
  • 23
  • 31

1 Answers1

0

You can get bitmap depth from Adroid.Graphics.Bitmap.Config property :

Bitmap.Config ARGB_4444 16 
Bitmap.Config ARGB_8888 32 
Bitmap.Config RGB_565 16  R5 G6 B5 ,no ALPHA
SimpleCoder
  • 80
  • 2
  • 5
  • Perfect, I did see that but it seems like a very limited number of bit depth options compared to the sample I included so wasn't sure if it was correct! Thanks for your answer! – Darrell Jun 05 '15 at 11:40