I have an image source of type System.Windows.Media.Imaging.ImageSource and I was wondering how I could get its resolution/size as well as modify the actual source data to change the file si开发者_Python百科ze and image dimensions.
You can cast it to BitmapSource
and then access those properties.
if (theImage.ImageSource is BitmapSource)
{
BitmapSource bitmap = (BitmapSource)theImage.ImageSource;
int width = bitmap.Width;
}
Here is more info on the BitmapSource class.
精彩评论