How can I determine the size of an ImageSource in pixels? The ImageSource object has a Height and a Width property, but they return the size in 1/96 inches..
Super old post, but for anyone else having problems with this, you don't have to do anything crazy or complicated.
(ImageSource.Source as BitmapSource).PixelWidth
(ImageSource.Source as BitmapSource).PixelHeight
There are 2 types of ImageSource: DrawingImage and BitmapSource.
Obviously, DrawingImage does not have DPI or pixel width, because it's essentially vector graphic.
On other side, BitmapSource has PixeWidth/PixelHeight and also DpiX/DpiY.
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapsource.pixelheight.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With