C# 使用BitmapFrame快速获取图像尺寸和分辨率

 

public void getImg(string filename, out Size JpgSize, out float Wpx, out float Hpx)
{
		try
		{
			Uri url = new Uri(filename);
			BitmapFrame bi = BitmapFrame.Create(url, BitmapCreateOptions.IgnoreColorProfile, BitmapCacheOption.OnDemand);
			int w = bi.PixelHeight;
			int h = bi.PixelWidth;
			JpgSize = new Size(w, h);
			Wpx = (float)bi.DpiX;//分辨率
			Hpx = (float)bi.DpiY;//分辨率
		}
		catch
		{
			JpgSize = new Size(0, 0);
			Wpx = 0; Hpx = 0;
		}
 }

 

© 版权声明
THE END
喜欢就支持一下吧
点赞5 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片快捷回复

    请登录后查看评论内容