本文介绍了如何验证图像和裁剪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想验证图片,验证其高度和宽度 用户尝试上传时,如果使用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);
}



}

解决方案


这篇关于如何验证图像和裁剪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 00:17