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;