开发者

Changing a System.Windows.Media.Imaging.ImageSource Image size/resolution?

开发者 https://www.devze.com 2023-02-18 07:54 出处:网络
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开发者_Pyt

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消