Webcam Bilder in Galerie

  • VB.NET

    Webcam Bilder in Galerie

    Hallo Liebe Leute,
    Ich komme direkt zum Problem, da ich wenn ich erlig bin keine Ahnung von Schnittstellen Prog. habe.
    Habe im Netz einen Code gefunden mit dem ich via Webcam, Bilder machen kann und speichere.
    Nun zu meiner Frage, wer ist so nett und kann mir sagen wie ich das Livebild so groß bekomme wie meine Pic Box???
    Eine direkte Lösung wäre super, da ich wie gesagt absolut keine Ahnung habe.
    Meine Webcam ist eine Microsoft mit 1080p.

    VB.NET-Quellcode

    1. Public Class Form1
    2. Dim Picture As System.Drawing.Image
    3. Public videoHandle As IntPtr
    4. Private Declare Auto Function SendMessage Lib "user32" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    5. Const EM_LINEFROMCHAR As Integer = &HC9
    6. Const EM_LINEINDEX As Integer = &HBB
    7. Private Declare Auto Function capCreateCaptureWindow Lib "avicap32.dll" (ByVal lpszWindowName As String, ByVal dwStyle As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hWndParent As IntPtr, ByVal nID As Integer) As IntPtr
    8. Private Const WS_CHILD As Integer = &H40000000
    9. Private Const WS_VISIBLE As Integer = &H10000000
    10. Private Const WM_USER As Short = &H400S
    11. Private Const WM_CAP_START As Short = &H400S
    12. Private Const WM_CAP_EDIT_COPY As Integer = (WM_CAP_START + 30)
    13. Private Const WM_CAP_DRIVER_CONNECT As Integer = (WM_CAP_START + 10)
    14. Private Const WM_CAP_SET_PREVIEWRATE As Integer = (WM_CAP_START + 52)
    15. Private Const WM_CAP_SET_OVERLAY As Integer = (WM_CAP_START + 51)
    16. Private Const WM_CAP_SET_PREVIEW As Integer = (WM_CAP_START + 50)
    17. Private Const WM_CAP_DRIVER_DISCONNECT As Integer = (WM_CAP_START + 11)
    18. Public Function CreateCaptureWindow(ByRef hWndParent As IntPtr, Optional ByRef x As Integer = 0, Optional ByRef y As Integer = 0, Optional ByRef nWidth As Integer = 1920, Optional ByRef nHeight As Integer = 1080, Optional ByRef nCameraID As Integer = 0) As IntPtr
    19. Dim previewHandle As IntPtr
    20. previewHandle = capCreateCaptureWindow("Video", WS_CHILD + WS_VISIBLE, x, y, nWidth, nHeight, hWndParent, 1)
    21. SendMessage(previewHandle, WM_CAP_DRIVER_CONNECT, nCameraID, 0)
    22. SendMessage(previewHandle, WM_CAP_SET_PREVIEWRATE, 30, 0)
    23. SendMessage(previewHandle, WM_CAP_SET_OVERLAY, 1, 0)
    24. SendMessage(previewHandle, WM_CAP_SET_PREVIEW, 1, 0)
    25. Return previewHandle
    26. End Function
    27. Public Function CapturePicture(ByRef nCaptureHandle As IntPtr) As System.Drawing.Image
    28. My.Computer.Clipboard.Clear()
    29. SendMessage(nCaptureHandle, WM_CAP_EDIT_COPY, 0, 0)
    30. Return My.Computer.Clipboard.GetImage
    31. End Function
    32. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    33. End Sub
    34. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    35. videoHandle = Me.CreateCaptureWindow(Me.PictureBox1.Handle)
    36. End Sub
    37. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    38. Picture = CapturePicture(videoHandle)
    39. Picture.Save(My.Computer.FileSystem.SpecialDirectories.Desktop + "\" + "pic.bmp")
    40. End Sub
    41. End Class


    *Topic verschoben*

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Marcus Gräfe“ ()