also include ist die escapi.pbi die hier ja schon zu massen gepostet ist! und dann eben dieser code! ich habe keinen plan woran das mit de buffern liegt! vielleicht weil sie alle 3 nacheinander angelegt werden und auch gleich groß sind... wer weiß
Code: Alles auswählen
EnableExplicit
UseTGAImageDecoder()
IncludeFile "escapi.pbi"
Structure TGA_HEADER
identsize.a
colourmaptype.a
imagetype.a
colourmapstart.u
colourmaplength.u
colourmapbits.a
xstart.u
ystart.u
width.u
height.u
bits.a
descriptor.a
; pixel data follows header
EndStructure
Global quit
Define deviceno.l, version.l, count.l, *namebuffer.i, bufferlength.l, name$
Define width, height, *pImage0.i, *pImage1.i, *pImage2.i
Define header.TGA_HEADER
Define scp0.SimpleCapParams, scp1.SimpleCapParams, scp2.SimpleCapParams
Global currentDeviceno
Global currentBuffer
deviceno = 0
width = 320
height = 240
Procedure output0(buffer)
Protected StartTime=-1
Repeat
If StartTime = -1
StartTime = ElapsedMilliseconds()
EndIf
If quit = 0 And ElapsedMilliseconds()-StartTime>40
StartTime = -1
doCapture(0)
CatchImage(0, buffer)
SetGadgetState(0, ImageID(0))
EndIf
Until quit
deinitCapture(0)
EndProcedure
Procedure output1(buffer)
Protected StartTime=-1
Repeat
If StartTime = -1
StartTime = ElapsedMilliseconds()
EndIf
If quit = 0 And ElapsedMilliseconds()-StartTime>40
StartTime = -1
doCapture(1)
CatchImage(1, buffer)
SetGadgetState(1, ImageID(1))
Delay(10)
EndIf
Until quit
deinitCapture(1)
EndProcedure
Procedure output2(buffer)
Protected StartTime=-1
Repeat
If StartTime = -1
StartTime = ElapsedMilliseconds()
EndIf
If quit = 0 And ElapsedMilliseconds()-StartTime>40
StartTime = -1
doCapture(2)
CatchImage(2, buffer)
SetGadgetState(2, ImageID(2))
Delay(10)
EndIf
Until quit
deinitCapture(2)
EndProcedure
If escapiOpen()
version = ESCAPIDLLVersion()
; Debug "version: $" + RSet(Hex(version), 4, "0")
initCOM()
count = countCaptureDevices()
; Debug "count: " + Str(count)
If count > 0
*namebuffer = AllocateMemory(1000)
bufferlength = 1000
getCaptureDeviceName(deviceno, *namebuffer, bufferlength)
If *namebuffer > 0
name$ = PeekS(*namebuffer, -1, #PB_Ascii)
; Debug "name: " + name$
EndIf
header\imagetype = 2
header\width = width
header\height = height
header\bits = 32
header\descriptor = %11110100
*pImage0 = AllocateMemory(width * height * 4 + SizeOf(TGA_HEADER))
*pImage1 = AllocateMemory(width * height * 4 + SizeOf(TGA_HEADER))
*pImage2 = AllocateMemory(width * height * 4 + SizeOf(TGA_HEADER))
CopyMemory(@header, *pImage0, SizeOf(TGA_HEADER))
CopyMemory(@header, *pImage1, SizeOf(TGA_HEADER))
CopyMemory(@header, *pImage2, SizeOf(TGA_HEADER))
scp0\mWidth = width
scp0\mHeight = height
scp0\mTargetBuf = *pImage0 + SizeOf(TGA_HEADER)
scp1\mWidth = width
scp1\mHeight = height
scp1\mTargetBuf = *pImage1 + SizeOf(TGA_HEADER)
scp2\mWidth = width
scp2\mHeight = height
scp2\mTargetBuf = *pImage2 + SizeOf(TGA_HEADER)
; If initCapture(deviceno, @scp)
; Debug "cap init successful"
OpenWindow(0, 450, 200, 3*width, height+50, name$, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar)
ImageGadget(0, 0, 0, width, height, 0)
ImageGadget(1, width, 0, width, height, 0)
ImageGadget(2, 2*width, 0, width, height, 0)
ButtonGadget(3,width/2-width/4,height+10,width/2,30,"activate cam 1")
ButtonGadget(4,width/2-width/4+width,height+10,width/2,30,"activate cam 2")
ButtonGadget(5,width/2-width/4+2*width,height+10,width/2,30,"activate cam 3")
CreateImage(0, width, height)
SetGadgetState(0, ImageID(0))
CreateImage(1, width, height)
SetGadgetState(1, ImageID(1))
CreateImage(2, width, height)
SetGadgetState(2, ImageID(2))
Repeat
Select WaitWindowEvent(1)
Case #PB_Event_CloseWindow
quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 3
If initCapture(0,@scp0)
CreateThread(@output0(),*pImage0)
EndIf
Case 4
If initCapture(1,@scp1)
CreateThread(@output1(),*pImage1)
EndIf
Case 5
If initCapture(2,@scp2)
CreateThread(@output2(),*pImage2)
EndIf
EndSelect
EndSelect
Delay(10)
Until quit = 1
; Else
;
; Debug "init capture failed!"
;
; EndIf
If *namebuffer > 0
FreeMemory(*namebuffer)
EndIf
If *pImage0 > 0
FreeMemory(*pImage0)
EndIf
If *pImage1 > 0
FreeMemory(*pImage1)
EndIf
If *pImage2 > 0
FreeMemory(*pImage2)
EndIf
EndIf
escapiClose()
Else
MessageRequester("example", "DLL 'escapi.dll' nicht vorhanden!")
EndIf
End