Dim qrCodeEncoder__1 As New QRCodeEncoder()
Dim encoding As [String] = cboEncoding.Text
If encoding = "Byte" Then
qrCodeEncoder__1.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.[BYTE]
ElseIf encoding = "AlphaNumeric" Then
qrCodeEncoder__1.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC
ElseIf encoding = "Numeric" Then
qrCodeEncoder__1.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.NUMERIC
End If
Try
Dim scale As Integer = Convert.ToInt16(txtSize.Text)
qrCodeEncoder__1.QRCodeScale = scale
Catch ex As Exception
MessageBox.Show("Invalid size!")
Return
End Try
Try
Dim version As Integer = Convert.ToInt16(cboVersion.Text)
qrCodeEncoder__1.QRCodeVersion = version
Catch ex As Exception
MessageBox.Show("Invalid version !")
End Try
Dim errorCorrect As String = cboCorrectionLevel.Text
If errorCorrect = "L" Then
qrCodeEncoder__1.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L
ElseIf errorCorrect = "M" Then
qrCodeEncoder__1.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M
ElseIf errorCorrect = "Q" Then
qrCodeEncoder__1.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.Q
ElseIf errorCorrect = "H" Then
qrCodeEncoder__1.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H
End If
Dim image As Image
Dim data As [String] = txtEncodeData.Text
image = qrCodeEncoder__1.Encode(data)
picEncode.Image = image
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private mCapHwnd As Long
Private Const CONNECT As Long = 1034
Private Const DISCONNECT As Long = 1035
Private Const GET_FRAME As Long = 1084
Private Const COPY As Long = 1054
'Private Const WM_CAP_SET_VIDEOFORMAT = &H400 + 45
Private Declare Function capCreateCaptureWindow Lib "avicap32.dll" Alias "capCreateCaptureWindowA" (ByVal lpszWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hwndParent As Long, ByVal nID As Long) As Long
Private Sub Form_Load()
'Getting handle of camera window
mCapHwnd = capCreateCaptureWindow("WebcamCapture", 0, 0, 0, 320, 240, Me.hwnd, 0)
DoEvents
SendMessage mCapHwnd, CONNECT, 0, 0 'connecting to camera
Picture1.AutoRedraw = True
Timer1.Enabled = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
DoEvents: SendMessage mCapHwnd, DISCONNECT, 0, 0
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
'getting picture from camera
SendMessage mCapHwnd, GET_FRAME, 0, 0
SendMessage mCapHwnd, COPY, 0, 0
Picture1.Picture = Clipboard.GetData: Clipboard.Clear
End Sub