0
BitmapImageを作成すると、Heightパラメータによって... widthが指定されます。 私のコードは、エラーが表示されたら、私はできません。 C#BitmapImageの高さを取得する
private void button_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Bitmap files (*.bmp)|*.bmp";
openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
if (openFileDialog.ShowDialog() == true)
{
BitmapImage image = new BitmapImage(new Uri(openFileDialog.FileName));
int maxHeight = 100;
if(image.Height != maxHeight)
{
MessageBox.Show("Error with the size");
return;
}
FileTextBlock.Text = openFileDialog.FileName;
ImageWPF.Source = imageEndo;
}
}
100の高さ、及び16の幅のbitrmap画像とこの試み、image.Height 16を得ました。
代わりにPixelHeightを使用してください。https://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapsource.pixelheight(v=vs.110).aspx –
作業中!ありがとうございました ! – betsou
問題ありません、あなたは大歓迎です。 –