[英]C# Get a BitmapImage Height
当我创建一个BitmapImage时,Height参数给我...宽度。 这是我的代码,如果看到错误,我不会。
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。
多亏了Rand Random,我用PixelHeight而不是Height解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.