views:

839

answers:

4

I have a filename that leads to a picture. It is not an embedded resource. My bitmap object always tells me the resolution is 96x96 no matter what, how can I get the actual resolution. Thanks

A: 
try this (its in C#):


   Bitmap b = new Bitmap(IMAGE_NAME_LOCATION);

        Size s = b.Size;
        s.Height;
        s.Width;

Height & width are in pixels. The Height & width are the original pic's size.

Ganesh R.
A: 

If you're loading a file using Bitmap.FromFile("C:\whatever.jpg"), and the resulting Bitmap has a .Width of 96 and a .Height of 96, then that is the actual resolution of that image.

If what you're doing is loading a file into a PictureBox control by setting its Image property in the designer (and browsing for the file), then it may be that your PictureBox just happens to be 96x96 and the SizeMode is set to Stretch, which would make any file you load appear to be 96x96.

MusiGenesis
+2  A: 

96 sounds pretty accurate to me. I think you're confusing pixel dimension with resolution. Resolution is the number of dots per inch* (DPI), and 96 is a common number for graphics targeted at monitor display.

As mentioned, the Height and Width properties are probably what you're looking for.

*Note: technically, I should have said PPI, as dots and pixels aren't necessarily interchangeable.

Thorarin
A: 

It's simple:

Bitmaps don't contain resolution information. They are only an ordered collection of pixels. They're device-independent. You can show the same bitmap at different resolutions (pixels per inch) on two different devices.

The fact that your bitmap object has a resolution property is misleading.

JimC