webcam image capture, Copy dropping resolution?
webcam image capture, Copy dropping resolution?
webcam image capture, Copy dropping resolution?
webcam image capture, Copy dropping resolution?
webcam image capture, Copy dropping resolution?
webcam image capture, Copy dropping resolution? webcam image capture, Copy dropping resolution? webcam image capture, Copy dropping resolution? webcam image capture, Copy dropping resolution? webcam image capture, Copy dropping resolution? webcam image capture, Copy dropping resolution? webcam image capture, Copy dropping resolution? webcam image capture, Copy dropping resolution?
webcam image capture, Copy dropping resolution? webcam image capture, Copy dropping resolution?
webcam image capture, Copy dropping resolution?
Go Back  Xtreme Visual Basic Talk > > > webcam image capture, Copy dropping resolution?


Reply
 
Thread Tools Display Modes
  #1  
Old 07-07-2012, 12:18 PM
Mrclauds Mrclauds is offline
Newcomer
 
Join Date: Feb 2011
Posts: 2
Default webcam image capture, Copy dropping resolution?


Hey guys

Im trying to capture a webcam image
The webcam is 1280x720
I can get it to preview on screen in this size, but as soon as I copy it to clipboard, it drops to 983 x 839 as seen in attributes in paint, and then when I copy it back into a second picturebox, it drops to 640x480?
i've been trying to solve this for days now, but to no avail...

below is the code:

Code:
Imports System
Imports System.IO
Imports System.Runtime.InteropServices
Imports Microsoft.Win32

Public Class Form1
    Inherits System.Windows.Forms.Form

    Const WM_CAP_START = &H400S
    Const WS_CHILD = &H40000000
    Const WS_VISIBLE = &H10000000
    Const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10
    Const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11
    Const WM_CAP_EDIT_COPY = WM_CAP_START + 30
    Const WM_CAP_SEQUENCE = WM_CAP_START + 62
    Const WM_CAP_FILE_SAVEAS = WM_CAP_START + 23
    Const WM_CAP_SET_SCALE = WM_CAP_START + 53
    Const WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52
    Const WM_CAP_SET_PREVIEW = WM_CAP_START + 50
    Const SWP_NOMOVE = &H2S
    Const SWP_NOSIZE = 1
    Const SWP_NOZORDER = &H4S
    Const HWND_BOTTOM = 1

    '--The capGetDriverDescription function retrieves the version
    ' description of the capture driver--
    Declare Function capGetDriverDescriptionA Lib "avicap32.dll" _
    (ByVal wDriverIndex As Short, _
    ByVal lpszName As String, ByVal cbName As Integer, _
    ByVal lpszVer As String, _
    ByVal cbVer As Integer) As Boolean

    '--The capCreateCaptureWindow function creates a capture window--
    Declare Function capCreateCaptureWindowA 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 Short, ByVal hWnd As Integer, _
    ByVal nID As Integer) As Integer

    '--This function sends the specified message to a window or windows--
    Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Integer, ByVal Msg As Integer, _
    ByVal wParam As Integer, _
    <MarshalAs(UnmanagedType.AsAny)> ByVal lParam As Object) As Integer

    '--Sets the position of the window relative to the screen buffer--
    Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" _
    (ByVal hwnd As Integer, _
    ByVal hWndInsertAfter As Integer, ByVal x As Integer, _
    ByVal y As Integer, _
    ByVal cx As Integer, ByVal cy As Integer, _
    ByVal wFlags As Integer) As Integer

    '--This function destroys the specified window--
    Declare Function DestroyWindow Lib "user32" _
    (ByVal hndw As Integer) As Boolean

    '---used to identify the video source---
    Dim CamSource As Integer

    '---used as a window handle---
    Dim hWnd As Integer

    Private Sub cameraSource()
        Dim DriverName As String = Space(80)
        Dim DriverVersion As String = Space(80)
        For i As Integer = 0 To 9
            If capGetDriverDescriptionA(i, DriverName, 80, DriverVersion, 80) Then
                ListBox1.Items.Add(DriverName.Trim)
            End If
        Next
    End Sub

    Private Sub previewCamera(ByVal pbCtrl As PictureBox)
        hWnd = capCreateCaptureWindowA(CamSource, WS_VISIBLE Or        WS_CHILD, 0, 0, 1280, 720, pbCtrl.Handle.ToInt32, 0)
        If SendMessage( _
        hWnd, WM_CAP_DRIVER_CONNECT, _
        CamSource, 0) Then
            '---set the preview scale---
            SendMessage(hWnd, WM_CAP_SET_SCALE, True, 0)
            '---set the preview rate (ms)---
            SendMessage(hWnd, WM_CAP_SET_PREVIEWRATE, 200, 0)
            '---start previewing the image---
            SendMessage(hWnd, WM_CAP_SET_PREVIEW, True, 0)
            '---resize window to fit in PictureBox control---
            SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 1280, 720, SWP_NOMOVE Or SWP_NOZORDER) 
        Else
            '--error connecting to video source---
            DestroyWindow(hWnd)
        End If

    Private Sub Bttncapture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bttncapture.Click
        ' Capture an image

        Dim img As Bitmap

        Dim data As IDataObject
        Dim bmap As Image
        ' Copy image to clipboard 
        SendMessage(hWnd, WM_CAP_EDIT_COPY, 0, 0)

        ' Get image from clipboard and convert it to a bitmap 
        data = Clipboard.GetDataObject()
        If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
            bmap = CType(data.GetData(GetType(System.Drawing.Bitmap)), Image)
            img = bmap
        End If
        PictureBox2.Image = img
    End Sub
End Class
Thanks so much

Last edited by Flyguy; 07-08-2012 at 03:47 AM. Reason: Replaced [color] tags with [code] tags
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
webcam image capture, Copy dropping resolution?
webcam image capture, Copy dropping resolution?
webcam image capture, Copy dropping resolution? webcam image capture, Copy dropping resolution?
webcam image capture, Copy dropping resolution?
webcam image capture, Copy dropping resolution?
webcam image capture, Copy dropping resolution? webcam image capture, Copy dropping resolution? webcam image capture, Copy dropping resolution? webcam image capture, Copy dropping resolution? webcam image capture, Copy dropping resolution? webcam image capture, Copy dropping resolution? webcam image capture, Copy dropping resolution?
webcam image capture, Copy dropping resolution?
webcam image capture, Copy dropping resolution?
 
webcam image capture, Copy dropping resolution?
webcam image capture, Copy dropping resolution?
 
-->