Hi
For an application I've created to help me at work I am confused with a part which is set to check image Bit Depth.
When checking the properties of the image file manually for the intended image it clearly shows 24 via the widows folder properties. when the same image is checked via my code a result of 32 is shown.
My coding below has been simplified with the removal of folder loop and listbox for testing purpose and I still receive a result of 32 BitDepth.
The coding is;
string ima = @"E:\Images\ImagesLM\44005W30.jpg";
var source = new BitmapImage(new Uri(ima));
bitsPerPixel = source.Format.BitsPerPixel;
MessageBox.Show(bitsPerPixel.ToString());
var source = new BitmapImage(new Uri(ima));
bitsPerPixel = source.Format.BitsPerPixel;
MessageBox.Show(bitsPerPixel.ToString());
I apologise if I'm using incorrect terminology as I'm am not a trained computer programmer and have google learnt all I have required for this project.
Thanks in advance,
Mark
Tuhin PaulPosted Apr 28, 2023, 2:25 AM
The BitmapImage class in your code is used to load images in WPF applications, which means that it is working with WPF pixel formats rather than file formats. The Format property of the BitmapImage class is returning the pixel format of the image, which is not the same as the file format's bit depth. The pixel format of an image determines the number of bits used to represent the color of each pixel, which can be different from the file format's bit depth, which determines the number of bits used to represent the color of the entire image.
Marvin ReidPosted Apr 12, 2023, 8:41 PM
You can use the RasterCodecs class to load your file, and then accurately get the Bit Depth of the image by accessing the BitsPerPixel property. Here is an example:
https://www.leadtools.com/help/sdk/v22/dh/co/rastercodecs-getinformation(string,bool).html
Raja TPosted Jul 11, 2016, 7:23 AM