我有一个问题,我想使用vb.net中的“打开文件对话框”将图像存储到位图中。如何实现呢?
我有此代码:
let v = dictionary["One"]
if let v1 = v as? FloatEntity
{
...
}
我在Dim image1 As Bitmap
Private Sub add_image_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles add_image.LinkClicked
With OpenFileDialog1
.Filter = ("Images | *.png; *.bmp; *.jpg;")
.FilterIndex = 2
End With
OpenFileDialog1.FileName = "Select Image"
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
image1 = OpenFileDialog1.FileName
End If
End Sub
中收到错误,我知道这是错误的。是否可以将所选图像存储在image1 = OpenFileDialog1.FileName
到OpenFileDialog1
中?
答案 0 :(得分:2)
尝试一下:
image1 = Image.FromFile(OpenFileDialog1.FileName)