how to get Bitsperpixel from a bitmap

后端 未结 6 1975
心在旅途
心在旅途 2021-02-18 12:41

I have a 3rd party component which requires me to give it the bitsperpixel from a bitmap.

What\'s the best way to get \"bits per pixel\"?

My starting point is th

6条回答
  •  北恋
    北恋 (楼主)
    2021-02-18 13:27

    var source = new BitmapImage(new System.Uri(pathToImageFile));
    int bitsPerPixel = source.Format.BitsPerPixel;
    

    The code above requires at least .NET 3.0

    http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapimage.aspx

提交回复
热议问题