PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Capstill.dll Memcopy und Fehlererkennung



Sommer
21.06.2006, 21:25
Hi Freaks!

ich habe ein kleines Problem.
Wenn ich das AktivWindow von meiner TV Karte in eine Picturebox Kopiere und das Signal ausfällt hängt sich die Software aus :-(

Nehme ich die Memcopy Funktion heraus was jedoch bedautet das meine Bildverarbeitung nicht funtzt läuft die Soft stabil (also Video ohne Kopie in die Picturebox)

Hier ein Code Ausschnitt... die Funktion wird über einen Timer aufgerufen!


' GDI functions to draw a DIBSection into a DC
Private Declare Function CreateCompatibleDC Lib "GDI32" _
(ByVal hdc As Long) As Long
Private Declare Function SelectObject Lib "GDI32" _
(ByVal hdc As Long, ByVal hbitmap As Long) As Long
Private Declare Function BitBlt Lib "GDI32" _
(ByVal hdc As Long, ByVal x As Long, ByVal y As Long, _
ByVal width As Long, ByVal height As Long, _
ByVal hdcSrc As Long, ByVal xSrc As Long, ByVal ySrc As Long, _
ByVal mode As Long) _
As Long
Private Declare Sub DeleteDC Lib "GDI32" _
(ByVal hdc As Long)
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(dest As Any, src As Any, ByVal count As Long)

Public Sub preview_Picture1()
'Kopiert das Videobild vom ActivWindow in die Picturebox Haubfenster
'benötigt werden dabei ShowBitmap
Dim bma As IBitmapAccess
On Error Resume Next
If CameraRun = True Then
Set bma = gCapStill.CapToMem
ShowBitmap bma
End If
End Sub

Public Sub ShowBitmap(bma As IBitmapAccess)
' set correct size of image and then
' BitBlt to the picture control's HDC

'Haubtfenster.Picture1.width = bma.width * Screen.TwipsPerPixelX
'Haubtfenster.Picture1.height = bma.height * Screen.TwipsPerPixelY

Dim hbm As Long
On Error Resume Next
hbm = bma.DIBSection

Dim hMemDc As Long
hMemDc = CreateCompatibleDC(Haubtfenster.Picture1.hdc)
Dim hOldBM As Long
hOldBM = SelectObject(hMemDc, hbm)
BitBlt Haubtfenster.Picture1.hdc, _
0, 0, bma.width, bma.height, _
hMemDc, 0, 0, &HCC0020
SelectObject hMemDc, hOldBM
DeleteDC hMemDc
'hbm is owned by the BMA object

Haubtfenster.Picture1.Refresh
End If
End Sub

Ich verwende die Capstill.dll

Vieleicht kan mir jemand einen Tip geben wie ich das Problem behebe.

Bye Ulli