Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 C# 新手,我将构建一个小型应用程序作为个人挑战。我在应用程序中处理了很多图像,并且已经到了需要获取图像大小来计算它们的比例的地步。所有的图像都是 .png 格式(我最喜欢的图像格式有很多原因)。我如何能够从文件中返回以像素为单位的宽度和高度?
此代码可以帮助您:
BitmapImage bit = new BitmapImage(new Uri(@"C:\myImage.png")); var h = bit.PixelHeight; var w = bit.PixelWidth;