当前位置:编程学习 > VB >>

如何把获取的视频图像完整显示在picture1控件中?

 由于摄像头分辨率为720x576  其分辨率修改不了 如何才能把图像完整显示在picture1控件中呢picture1大小为320x240?现在只能显示部分图像
     视频获取TVideoGrabber工具来获取的(主要针对CCD或CMOS传感器),使用了VideoGrabberVB6控件,较常规API函数(对一般的USB摄像头:QQ聊天之类的摄像头)速度更快。

Private Sub Command1_Click()
 VideoGrabberVB61.StartPreview
End Sub

Private Sub Command2_Click()
 VideoGrabberVB61.StopPreview
End Sub

Private Sub Command3_Click()
 VideoGrabberVB61.BurstType = fc_TBitmap  
 VideoGrabberVB61.BurstMode = True      
 ipoint = 0
End Sub

Private Sub Command4_Click()
   VideoGrabberVB61.ShowDialog (dlg_VideoDevice)
End Sub

Private Sub Command5_Click()
  VideoGrabberVB61.ShowDialog (dlg_StreamConfig)
End Sub

Private Sub Command6_Click()
    VideoGrabberVB61.CaptureFrameTo fc_JpegFile, ""
End Sub




Private Sub Form_Load()
  VideoGrabberVB61.BurstMode = False
  Text1.Text = VideoGrabberVB61.StoragePath
End Sub

Private Sub Timer1_Timer()
    VideoGrabberVB61.BurstType = fc_TBitmap
    VideoGrabberVB61.BurstMode = True
    ipoint = 1
End Sub

Private Sub VideoGrabberVB61_OnFrameCaptureCompleted(ByVal FrameBitmapHandle As Long, ByVal BitmapWidth As Long, ByVal BitmapHeight As Long, ByVal FrameNumber As Long, ByVal FrameTime As Double, ByVal DestType As vidgrab_VB6.TxFrameCaptureDest, ByVal FileName As String, ByVal Success As Boolean, ByVal FrameId As Long)
  
    Dim nDC As Long
    Dim OldBitmap As Long

    If VideoGrabberVB61.BurstMode = True Then

'        SnapForm.SnapImage.Width = Screen.TwipsPerPixelX * BitmapWidth
'        SnapForm.SnapImage.Height = Screen.TwipsPerPixelY * BitmapHeight
'        SnapForm.Width = SnapForm.SnapImage.Width + SnapForm.Width - SnapForm.ScaleWidth
'        SnapForm.Height = SnapForm.SnapImage.Height + SnapForm.Height - SnapForm.ScaleHeight
'       Picture1.Width = Screen.TwipsPerPixelX * BitmapWidth
'       Picture1.Height = Screen.TwipsPerPixelY * BitmapHeight

        Text2.Text = Screen.TwipsPerPixelX  '返回屏幕中每一个像素中的缇数。一个是垂直中的像素,一个是水平中的像素。
        Text3.Text = BitmapWidth
        Text4.Text = Screen.TwipsPerPixelY
        Text5.Text = BitmapHeight
    
                 nDC = CreateCompatibleDC(0&)        '创建一个与特定设备场景一致的内存设备场景
                 OldBitmap = SelectObject(nDC, FrameBitmapHandle)

                 If ipoint = 0 Then
                       Call BitBlt(Picture1.hdc, 0, 0, BitmapWidth, BitmapHeight, nDC, 0, 0, vbSrcCopy) 'vbSrcCopy:拷贝源位图到目标位图
                       Call SelectObject(nDC, OldBitmap)
                       Call DeleteDC(nDC)
                       Picture1.Refresh
                       Picture1.AutoRedraw = True
                       Timer1.Interval = 50
                       Timer1.Enabled = True
                End If
                
                If ipoint = 1 Then
                       Call BitBlt(Picture2.hdc, 0, 0, BitmapWidth, BitmapHeight, nDC, 0, 0, vbSrcCopy)
                       Call SelectObject(nDC, OldBitmap)
                       Call DeleteDC(nDC)
                       Picture2.Refresh
                       Picture2.AutoRedraw = True
                End If
     End If
End Sub

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal XSrc As Long, ByVal YSrc As Long, ByVal dwRop As Long) As Long
Public Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Public Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long

Public Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long 问题后面这堆代码是干嘛的?好用的还是不能用的?贴出来干嘛? http://download.csdn.net/source/2979383
补充:VB ,  基础类
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,