eie toy for windows ;)
look at my worklog please
now with blue box (chroma key)
mfg panno

; *********** IRDRAW 0.00001 - TV Remotecontrol Painting - Brought to you by CSP *********** ; Credit to PANNO - thanks for the incredible WEBCAM.DLL !!! ; For this you need a TV-RC and a Webcam. Webcam settings MUST be 320*240 in 24 Bit! ; The Picture must be relatively dark with low contrast. AppTitle "IRDRAW 0.00001 - TV Remotecontrol Painting" Global hwnd_width=640 Global hwnd_height=480 Graphics3D hwnd_width,hwnd_height,32,2 ; btw: also works in fullscreen! :) ;This is an Input device, the Infrared Point of a TV Remotecontrol, when aimed to a camera ;IRDot is 1 if a button was pressed (something like mousedown()) Global IRDot,IRDotX,IRDotY Global IRDotBrightness=650 ; (max=765=white) Global IRDotSize=2 Global WebcamRefresh=100 ; Camera texture refresh every n millisecs Global in_bank = CreateBank(1) ; ask PANNO :) Global out_bank = CreateBank (321*241*4): ; 320*240 pixels for image exchange with DLL Global img = CreateImage (320,256) ; used as a buffer for webcam image camera=CreateCamera() CameraClsMode camera,0,1 Global tex=CreateTexture(256,256,256) ; screen-covering sprite semitransparent webcam image ols=CreateSprite() EntityTexture ols,tex ScaleTexture tex,-1,1 TranslateEntity ols,0,0,1.0 EntityBlend ols,3 EntityFX ols,1 cube=CreateCube() ; had to add this since radeon 9200 is somehow crazy TranslateEntity cube,16,12,20 ok = CallDLL("B3DCAPtest","INIT",in_bank,Out_bank); Delect WebCam Device ok = CallDLL ("B3DCAPtest","START"); start thread that will continuelsy copy webcam images to our bank!! SetBuffer BackBuffer() font=LoadFont("arial",32) SetFont font butth=40 ; initialize some buttons and stuff butt1$=" Clearcanvas " butt1x=0 butt1w=StringWidth(butt1$) Global doodle=CreateImage(hwnd_width,hwnd_height-butth) rgbimg=CreateImage(256,butth-1) ; colorpick palette SetBuffer ImageBuffer(rgbimg) jstep#=butth/255.0 For j=0 To 255 For i=0 To 255 Color i, j ,Abs(127-j) Plot i,yj# Next yj#=yj#+jstep# Next SetBuffer BackBuffer() butt2x=butt1w butt2w=256 draw_r=255 draw_g=255 draw_b=255 ; -----------------------------------------MAIN LOOP-------------------------------------- While Not(KeyHit(1)) Cls m_old=m m=MilliSecs() If m>next_refresh Then WebCamJobs() next_refresh=m+WebcamRefresh EndIf If IRDot=1 ; TV-RC Button pressed? SetBuffer ImageBuffer(doodle) Color draw_r,draw_g,draw_b If old_IRDot=1 Line IRDotX,IRDotY-(butth),old_IRDotX,old_IRDotY-(butth) Else Plot IRDotX,IRDotY-(butth) EndIf SetBuffer BackBuffer() EndIf old_IRDot=IRDot old_IRDotX=IRDotX old_IRDotY=IRDotY DrawImage doodle,0,butth ; overlay masked painting-canvas ; draw buttons etc. Color 100,100,100 Rect butt1x,0,butt1w,butth-1,0 Text butt1x,butth/2,butt1$,0,1 DrawBlock rgbimg,butt1w,0 ; show pickable palette Color draw_r,draw_g,draw_b Rect butt2x+butt2w+10,0,100,butth-1,1 ; show current color ; preform button actions if required If IRDot=1 And IRDotY<butth Then If IRDotX>butt1x And IRDotX<butt1x+butt1w ; CLS SetBuffer ImageBuffer(doodle) Color 0,0,0 Rect 0,0,hwnd_width,hwnd_height-butth SetBuffer BackBuffer() IRDot=0 EndIf If IRDotX>butt2x And IRDotX<butt2x+butt2w ; select color SetBuffer ImageBuffer(rgbimg) rgb=ReadPixel(IRDotX-butt2x,IRDotY) SetBuffer BackBuffer() draw_r=(rgb Shr 16) And $ff draw_g=(rgb Shr 8) And $ff draw_b=(rgb And $ff) IRDot=0 EndIf EndIf ;Text hwnd_width-40,10,m-m_old ;DrawBlock img,MouseX(),MouseY() RenderWorld Flip Wend ok = CallDLL("B3dCAPtest","ENDCAP") ; leave nicely EndGraphics() End ; --------------------------------------end of main loop-------------------------------------- Function WebCamJobs() IRDot=0 ; flush Buttonstate cbright=0 SetBuffer ImageBuffer(img) LockBuffer ImageBuffer(img) pointer =0 For LoopX = 32 To 287 ; copy neccessary part from bank to image... For LoopY = 24 To 215 Pointer = (Loopy+(Loopx*240))*4 argb = PeekInt(out_bank,pointer) WritePixelFast(Loopx-32,Loopy,argb) r=argb Shr 16 g=(argb Shr 8) And $ff b=argb And $ff sum=r+g+b If sum>IRDotBrightness ; (find White IR-Dot) cbright=cbright+1 If cbright>=IRDotSize IRDot=1 IRDotX=hwnd_width-(((loopx-32)/256.0)*hwnd_width) IRDotY=((loopy-24)/192.0)*hwnd_height EndIf Else cbright=0 EndIf Next Next UnlockBuffer ImageBuffer(img) CopyRect 0,0,256,256,0,8,ImageBuffer(img),TextureBuffer(tex) ; ...and from image to texture SetBuffer BackBuffer() ; maybe it would be better to move it directly from bank to texture. However... End Function

initialize capture while game read image from bank send single grab request to dll ... renderworld flip wend endcap thing