Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picNo.Click
With ofDlg
.Title = "เลือกรูปภาพ"
.Filter = "Image File(*.jpg; *.Jpeg;)|*.jpg; *.Jpeg"
.FileName = ""
.Multiselect = False
.FilterIndex = 0
If .ShowDialog() = Windows.Forms.DialogResult.OK Then
txtPicPath.Text = .FileName
picNo.ImageLocation = txtPicPath.Text
'btBW.Image = Image.FromFile(tmpPicFileName)
End If
picNo.Image = picNo.ErrorImage
End With
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dateString As String
Dim dateSc As String
Dim ReIma As String
Dim path As String
dateString = Format$(Now.Date, "ddMMyy")
dateSc = Format$(Now.Hour) & (Now.Minute) & (Now.Second)
ReIma = "Q" & dateString & dateSc
path = "\\192.168.1.78\New folder\" & ReIma & ".jpg" 'ที่จะเก็บไฟล์รูป กรณีในวงแลน
Dim bm As New Bitmap(txtPicPath.Text) 'ที่อยู่ Part และชื่อไฟล์ที่จะ ลดขนาด
Dim width As Integer = 90 '-ขนาดที่ต้องการจะลด
Dim height As Integer = (90 * bm.Height) / bm.Width 'image height
Dim thumb As New Bitmap(width, height)
Dim g As Graphics = Graphics.FromImage(thumb)
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(bm, New Rectangle(0, 0, width, height), New Rectangle(0, 0, bm.Width, _
bm.Height), GraphicsUnit.Pixel)
g.Dispose()
bm.Dispose()
thumb.Save(path, _
System.Drawing.Imaging.ImageFormat.Jpeg) 'can use any image format
thumb.Dispose()
End Sub