问题描述
我想验证图片,验证其高度和宽度 用户尝试上传时,如果使用upload 作为定义图像大小,以便他可以允许做裁剪 as 每个定义高度和宽度我编写代码用于图像验证,但它不起作用我执行调试但代码不在如果条件我突出显示
我尝试过:
OpenFileDialog openfd = new OpenFileDialog();
openfd.Filter =仅图片。| * .jpg; * .jpeg; * .png; * .gif;;
if(openfd.ShowDialog()== DialogResult.OK )
{
** if(pictureBox6.Width< 120&& pictureBox6.Height< 173)
{
MessageBox.Show(大小无效);
} **
其他
{
pictureBox6.Image = new Bitmap(openfd.FileName);
}
}
i want to validate image , validate its height and width when user trying to upload, also if use upload as define image size so he can be allow to do crop as per define height and width i wrote code for image validation but its not working also i do debugging but code not going inside if condition which i highlighted
What I have tried:
OpenFileDialog openfd = new OpenFileDialog();
openfd.Filter = "Image only. |*.jpg; *.jpeg; *.png; *.gif;";
if (openfd.ShowDialog() == DialogResult.OK)
{
**if (pictureBox6.Width < 120 && pictureBox6.Height < 173)
{
MessageBox.Show("size invalid");
}**
else
{
pictureBox6.Image = new Bitmap(openfd.FileName);
}
}
这篇关于如何验证图像和裁剪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!