0

如果有人可以非常友好地告诉我如何在保存时将图片大小限制为指定尺寸(例如 150 x 200 像素),我会很高兴。如果不符合要求,则错误消息应指示所需尺寸。

但是,以下是将图片上传到图片框的代码。

Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
    Try
        OpenFileDialog1.ShowDialog()
        PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
        img = OpenFileDialog1.FileName.ToString
    Catch
    End Try
End Sub
4

1 回答 1

1
If Image.FromFile(OpenFileDialog1.FileName).Size.Width > 150 Or Image.FromFile(OpenFileDialog1.FileName).Size.Height > 200 Then 
   lblPhotoErr.Text = "More than 150 x 200"
   bError = True
End If
于 2013-01-02T11:40:33.190 回答