📄 frmoptions.frm
字号:
val = MV_SetDeviceParameter(hDevice, ADJUST_BACKCOLORKEY, &H400000)
Form1.SyncSet.Visible = False
Form1.test.Visible = False
Form1.CapFormat.Visible = True
Form1.TenBitMode.Visible = False
Form1.FilterSet.Visible = False
End If
Dim temp As Integer
temp = MV_GetDeviceParameter(hDevice, GARB_BITDESCRIBE)
Select Case temp
Case 0:
Form1.now.Caption = "当前格式:MONOCHOY8"
Case 1:
Form1.now.Caption = "当前格式:GBR1555"
Case 2:
Form1.now.Caption = "当前格式:CO_RGB24"
Case 3:
Form1.now.Caption = "当前格式:aRGB8888"
Case 4:
Form1.now.Caption = "当前格式:RGB8332"
Case 5:
Form1.now.Caption = "当前格式:CO_RGB565"
Case 6:
Form1.now.Caption = "当前格式:RGB5515"
Case 7:
Form1.now.Caption = "当前格式:CO_YUV444"
Case 8:
Form1.now.Caption = "当前格式:CO_YUV422"
Case 9:
Form1.now.Caption = "当前格式:YUV411"
End Select
Form1.Hint.Caption = "请刷新!"
'刷新
GetParmator
Form1.Refresh
Form1.DispArea.Refresh
End Sub
Private Sub Channel1_Click()
MV_SetDeviceParameter hDevice, ADJUST_CHANNEL, 0 '设置板卡采集通道为0通道
Form1.DispArea.Refresh
End Sub
Private Sub Channel2_Click()
MV_SetDeviceParameter hDevice, ADJUST_CHANNEL, 1 '设置板卡采集通道为1通道
Form1.DispArea.Refresh
End Sub
Private Sub Channel3_Click()
MV_SetDeviceParameter hDevice, ADJUST_CHANNEL, 2 '设置板卡采集通道为2通道
Form1.DispArea.Refresh
End Sub
Private Sub Channel4_Click()
MV_SetDeviceParameter hDevice, ADJUST_CHANNEL, 3 '设置板卡采集通道为3通道
Form1.DispArea.Refresh
End Sub
Private Sub Check1_Click()
If Check1.Value = 1 Then
If Bmp.Enabled = True And Bmp.Value = True Then
RGB15.Enabled = True
RGB16.Enabled = True
End If
Else
If Bmp.Enabled = True And Bmp.Value = True Then
RGB15.Enabled = False
RGB16.Enabled = False
End If
End If
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdApply_Click()
' MsgBox "Place code here to set options w/o closing dialog!"
If nBoardType = LEVIN_M10 Or nBoardType = LEVIN_M20 _
Or nBoardType = LEVIN_RGB10 Or nBoardType = LEVIN_RGB20 _
Or nBoardType = LEVIN_VGA100 Or nBoardType = LEVIN_VGA170 Then
MV_SetDeviceParameter hDevice, GARB_WIDTH, CptWdth.Text '设置采集窗口宽度
MV_SetDeviceParameter hDevice, GARB_HEIGHT, CptHght.Text '设置采集窗口高度
MV_SetDeviceParameter hDevice, DISP_WIDTH, DspWdth.Text '设置显示窗口宽度
MV_SetDeviceParameter hDevice, DISP_HEIGHT, DspHght.Text '设置显示窗口高度
Else
MV_SetDeviceParameter hDevice, GARB_IN_WIDTH, CptWdth.Text '设置采集输入宽度
MV_SetDeviceParameter hDevice, GARB_IN_HEIGHT, CptHght.Text '设置采集输入高度
MV_SetDeviceParameter hDevice, GARB_WIDTH, DspWdth.Text '设置采集输出宽度
MV_SetDeviceParameter hDevice, GARB_HEIGHT, DspHght.Text '设置采集输出高度
MV_SetDeviceParameter hDevice, DISP_WIDTH, DspWdth.Text '设置显示窗口宽度
MV_SetDeviceParameter hDevice, DISP_HEIGHT, DspHght.Text '设置显示窗口高度
End If
nQuality = JpgQult.Text
nFrmNo = FrmNum.Text
strFileDir = FileDir.Text
If Check1.Enabled = True Then
bSaveFilePro = Check1.Value
Else
bSaveFilePro = False
End If
If RGB15.Enabled = True Then
bIsRGB15 = RGB15.Value
Else
bIsRGB15 = False
End If
If Colorful.Enabled = True Then
bIsColor = Colorful.Value
Else
bIsColor = False
End If
If Bmp.Value = True Then
nFileFmt = 0
ElseIf Jpeg.Value = True Then
nFileFmt = 1
ElseIf Txt.Value = True Then
nFileFmt = 2
End If
Form1.DispArea.Refresh
End Sub
Private Sub cmdOK_Click()
' MsgBox "Place code here to set options and close dialog!"
If nBoardType = LEVIN_M10 Or nBoardType = LEVIN_M20 _
Or nBoardType = LEVIN_RGB10 Or nBoardType = LEVIN_RGB20 _
Or nBoardType = LEVIN_VGA100 Or nBoardType = LEVIN_VGA170 Then
MV_SetDeviceParameter hDevice, GARB_WIDTH, CptWdth.Text '设置采集窗口宽度
MV_SetDeviceParameter hDevice, GARB_HEIGHT, CptHght.Text '设置采集窗口高度
MV_SetDeviceParameter hDevice, DISP_WIDTH, DspWdth.Text '设置显示窗口宽度
MV_SetDeviceParameter hDevice, DISP_HEIGHT, DspHght.Text '设置显示窗口高度
Else
MV_SetDeviceParameter hDevice, GARB_IN_WIDTH, CptWdth.Text '设置采集输入宽度
MV_SetDeviceParameter hDevice, GARB_IN_HEIGHT, CptHght.Text '设置采集输入高度
MV_SetDeviceParameter hDevice, GARB_WIDTH, DspWdth.Text '设置采集输出宽度
MV_SetDeviceParameter hDevice, GARB_HEIGHT, DspHght.Text '设置采集输出高度
MV_SetDeviceParameter hDevice, DISP_WIDTH, DspWdth.Text '设置显示窗口宽度
MV_SetDeviceParameter hDevice, DISP_HEIGHT, DspHght.Text '设置显示窗口高度
End If
'if jpeg.Value =True then
nQuality = CInt(JpgQult.Text)
nFrmNo = CLng(FrmNum.Text)
strFileDir = FileDir.Text
If Check1.Enabled = True Then
bSaveFilePro = Check1.Value
Else
bSaveFilePro = False
End If
If RGB15.Enabled = True Then
bIsRGB15 = RGB15.Value
Else
bIsRGB15 = False
End If
If Colorful.Enabled = True Then
bIsColor = Colorful.Value
Else
bIsColor = False
End If
If Bmp.Value = True Then
nFileFmt = 0
ElseIf Jpeg.Value = True Then
nFileFmt = 1
ElseIf Txt.Value = True Then
nFileFmt = 2
End If
Form1.DispArea.Refresh
Unload Me
End Sub
Private Sub Colorful_Click()
Colorful.Value = True
RGB15.Enabled = True
RGB16.Enabled = True
End Sub
Private Sub CtrstSld_Change()
If nBoardType = LEVIN_RGB10 Or nBoardType = LEVIN_RGB20 _
Or nBoardType = LEVIN_VGA100 Or nBoardType = LEVIN_VGA170 Then '对于RGB,VGA卡
If Red.Value = True Then
MV_SetDeviceParameter hDevice, ADJUST_R_COARSE, CtrstSld.Value '设置红路亮度值
ElseIf Blue.Value = True Then
MV_SetDeviceParameter hDevice, ADJUST_B_COARSE, CtrstSld.Value '设置蓝路亮度值
Else
MV_SetDeviceParameter hDevice, ADJUST_G_COARSE, CtrstSld.Value '设置绿路亮度值
End If
Else
MV_SetDeviceParameter hDevice, ADJUST_R_COARSE, CtrstSld.Value '对于M10、M20,设置亮度值
End If
End Sub
Private Sub DirectShow_Click()
MV_SetDeviceParameter hDevice, BUFFERTYPE, 2 '设置显示方式为直接显存方式
Form1.DispArea.Refresh
End Sub
Private Sub DirectX_Click()
MV_SetDeviceParameter hDevice, BUFFERTYPE, 0 '设置显示方式为DirectX方式
Form1.DispArea.Refresh
End Sub
Private Sub DirSelect_Click()
Dim SaveFile As OPENFILENAME
Dim lReturn As Long
SaveFile.lStructSize = Len(SaveFile)
SaveFile.hwndOwner = frmOptions.hWnd
SaveFile.hInstance = App.hInstance
SaveFile.lpstrFile = String$(255, 0)
lReturn = Len(SaveFile.lpstrFile)
SaveFile.nMaxFile = Len(SaveFile.lpstrFile) - 1
SaveFile.nMaxFileTitle = SaveFile.nMaxFile
SaveFile.lpstrInitialDir = strFileDir
SaveFile.lpstrTitle = "存储路径设置"
SaveFile.flags = 0
lReturn = GetSaveFileName(SaveFile)
If lReturn Then
FileDir.Text = SaveFile.lpstrFile
End If
End Sub
Private Sub FLIPCh_Click()
If FlipCh.Value = 0 Then
MV_SetDeviceParameter hDevice, WORK_FLIP, 0 '设置视频图像不翻转
Else
MV_SetDeviceParameter hDevice, WORK_FLIP, 1 '设置视频图像水平翻转
End If
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, _
Shift As Integer)
Dim i As Integer
'handle ctrl+tab to move to the next tab
If Shift = vbCtrlMask And KeyCode = vbKeyTab Then
i = SetParametor.SelectedItem.Index
If i = SetParametor.Tabs.Count Then
'last tab so we need to wrap to tab 1
Set SetParametor.SelectedItem = SetParametor.Tabs(1)
Else
'increment the tab
Set SetParametor.SelectedItem = SetParametor.Tabs(i + 1)
End If
End If
End Sub
Private Sub Form_Load()
'显示总板卡数,初始化板卡选择下拉条
BoardNo.Text = nAmount
If BoardNo.Text = 1 Then
CardList.Enabled = False
End If
CardList.Text = strCardName(0)
Dim i As Integer
For i = 0 To nAmount - 1
CardList.AddItem strCardName(i), i
Next i
'开始子过程
GetParmator
End Sub
Private Sub GDI_Click()
' MV_OperateDevice Index, MVSTOP
MV_SetDeviceParameter hDevice, BUFFERTYPE, 1 '设置显示方式为GDI方式
' MV_SetDeviceParameter hDevice, DISP_WHND, Form1.hWnd '设置图像显示窗口句柄
' MV_OperateDevice hDevice, MVRUN '设置采集卡开始采集并显示图像
Form1.DispArea.Refresh
End Sub
Private Sub GetData_Click()
Dim i As Long
Dim mystr1 As String, mystr2 As String, mystr3 As String
Dim cutlen As Long
Dim rmax As Byte, rmin As Byte, gmax As Byte, gmin As Byte, bmax As Byte, bmin As Byte
Dim buffer() As Byte
Dim pdest() As Byte
' 界面初始化
DataHeight.Text = MV_GetDeviceParameter(hDevice, GARB_HEIGHT)
DataWidth.Text = MV_GetDeviceParameter(hDevice, GARB_WIDTH)
DataX.Text = 0
DataY.Text = 0
VideoData.Text = ""
' 利用当前采集的图像的信息,建立buffer,再抓取一帧放入buffer,并拷贝到pdest中
MV_SetDeviceParameter hDevice, SET_GARBIMAGEINFO, VarPtr(info)
ReDim buffer(info.Length) As Byte
For i = 0 To info.Length - 1
buffer(i) = 0
Next i
MV_CaptureSingle hDevice, False, VarPtr(buffer(0)), info.Length, info
ReDim pdest(info.Length) As Byte
cutlen = info.Length
For i = 0 To cutlen - 1
pdest(i) = buffer(i)
Next i
' 遍历图像数据,找出最大值和最小值
' 8位
If info.nColor = 8 Then
rmin = pdest(0)
rmax = rmin
For i = 1 To cutlen - 1
If pdest(i) > rmax Then
rmax = pdest(i)
ElseIf pdest(i) < rmin Then
rmin = pdest(i)
End If
Next i
' 最大值
If rmax > 0 Then
mystr1 = Format$(rmax, "最大值:####")
ElseIf rmax = 0 Then
mystr1 = Format$("最大值:0")
Else
mystr1 = Format$("最大值:错误")
End If
' 最小值
If rmin > 0 Then
mystr2 = Format$(rmin, "最小值:####")
ElseIf rmin = 0 Then
mystr2 = Format$("最小值:0")
Else
mystr2 = Format$("最小值:错误")
End If
mystr3 = mystr1 & vbCrLf & mystr2
VideoData.Text = "8bit模式" & vbCrLf & mystr3
' 32位
ElseIf info.nColor = 32 Then
rmin = pdest(2)
rmax = rmin
gmin = pdest(1)
gmax = gmin
bmin = pdest(0)
bmax = bmin
For i = 2 To cutlen - 1 Step 4 ' R
If pdest(i) > rmax Then
rmax = pdest(i)
ElseIf pdest(i) < rmin Then
rmin = pdest(i)
End If
Next i
For i = 1 To cutlen - 1 Step 4 ' G
If pdest(i) > gmax Then
gmax = pdest(i)
ElseIf pdest(i) < gmin Then
gmin = pdest(i)
End If
Next i
For i = 0 To cutlen - 1 Step 4 ' B
If pdest(i) > bmax Then
bmax = pdest(i)
ElseIf pdest(i) < bmin Then
bmin = pdest(i)
End If
Next i
'R
If rmax > 0 Then
mystr1 = Format$(rmax, "红色最大值:####")
ElseIf rmax = 0 Then
mystr1 = Format$("红色最大值:0")
Else
mystr1 = Format$("红色最大值:错误")
End If
If rmin > 0 Then
mystr2 = Format$(rmin, "红色最小值:####")
ElseIf rmin = 0 Then
mystr2 = Format$("红色最小值:0")
Else
mystr2 = Format$("红色最小值:错误")
End If
mystr3 = mystr1 & vbCrLf & mystr2
'G
If gmax > 0 Then
mystr1 = Format$(gmax, "绿色最大值:###")
ElseIf gmax = 0 Then
mystr1 = Format$("绿色最大值:0")
Else
mystr1 = Format$("绿色最大值:错误")
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -