Webcam and purebasic

Mac OSX specific forum
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: Webcam and purebasic

Post by jesperbrannmark »

Like this? (i dont get it running as it should)

Code: Select all

UseJPEG2000ImageEncoder()
Procedure UpdateSnapshot()
  Image = MXSnapshot_TakeSnapshot(320)
  tempimage=CreateImage(#PB_Any,320,240)
  StartDrawing(ImageOutput(tempimage))
  DrawImage(image,0,0,320,240)
  StopDrawing()
  SaveImage(tempimage,GetTemporaryDirectory()+"test.jpg",#PB_ImagePlugin_JPEG,6)
  FreeImage(tempimage)
  SetGadgetState(0, Image)
  MX_Release(Image)
EndProcedure

If OpenWindow(0, 0, 0, 320, 256, "Snapshot example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ImageGadget(0, 0, 0, 320, 256, 0)
  UpdateSnapShot()
  AddWindowTimer(0, 0, 500)
  Repeat
    Event = WaitWindowEvent()
    If Event = #PB_Event_Timer
      UpdateSnapshot()
    EndIf
  Until Event = #PB_Event_CloseWindow
  MXSnapshot_StopSession()
EndIf
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Webcam and purebasic

Post by wilbert »

You should use
UseJPEGImageEncoder()
instead of
UseJPEG2000ImageEncoder()
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: Webcam and purebasic

Post by jesperbrannmark »

Duh. Thats what happens when you type faster than what you think..
Thanks
J
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Choose webcam and PB

Post by jesperbrannmark »

With the MXSnapshot_TakeSnapshot - is there any way of selecting webcam? (I have a external camera, and only the internal is used)
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Choose webcam and PB

Post by wilbert »

jesperbrannmark wrote:With the MXSnapshot_TakeSnapshot - is there any way of selecting webcam? (I have a external camera, and only the internal is used)
Not at this time.
Currently it uses defaultInputDeviceWithMediaType: from the QTCaptureDevice class .
Post Reply