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.
<Image>WPF要素 のソースイメージに関する情報を取得するにはどうすればよいですか?
<Image>
私の<Image>要素のSourceはImageSourceプロパティにバインドされており、頻繁に変更されます。私のコードビハインドでは、数学的な目的で、現在のソース画像ファイルの実際の幅(通常のピクセル単位)にアクセスできる必要があります。私のアプリケーションは画像ファイルに対して画像操作を実行するので、この情報が必要です。
どんな助けでも大歓迎です。
私はこれがあなたのために働くかもしれないと思います:
BitmapSource sourceData = image.Source as BitmapSource; int width = sourceData.PixelWidth; int height = sourceData.PixelHeight;