Easy get one pic of webcam device and save it

Just starting out? Need help? Post your questions and find answers here.
omid-xp
Enthusiast
Enthusiast
Posts: 119
Joined: Tue Jan 27, 2004 2:17 pm

Easy get one pic of webcam device and save it

Post by omid-xp »

How can i easy get one pic of webcam device and save it to disk ?

I know exist an source code for webcam but it is very big and it not save pic to disk and just view webcam in an window .

I try to change it but can't, try to use avicap library but it is in other language and i can't use it.

I need just to one easy and small source.

Can some one help me for this ?

Why PureBasic not good support webcam ? just exist one source code for it and it just show in one window. if search forums for webcam just can find source for webcams online of website, but not exist anything for webcam device , in commands and library of purebasic just exist command for change view camera in games, it is just for game apps and is not for webcam device !

Its not really good.

special thanks.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Use the search function to find "twain scan" someone posted code about connecting to twain drivers and retrieve scanned / video input from devices that have such a driver :wink:
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Re: Easy get one pic of webcam device and save it

Post by Rings »

omid-xp wrote:I try to change it but can't, try to use avicap library but it is in other language and i can't use it.
Why PureBasic not good support webcam ?
Its not really good.
what you need is a simple Click-Drag&Drop-Coding-Software for appz like Click&Play for gamez, a art of visual editor with every command you dream inbuild ........ , just a VISUAL DREAMER :mrgreen:
SPAMINATOR NR.1
omid-xp
Enthusiast
Enthusiast
Posts: 119
Joined: Tue Jan 27, 2004 2:17 pm

Re: Easy get one pic of webcam device and save it

Post by omid-xp »

Rings wrote:what you need is a simple Click-Drag&Drop-Coding-Software for appz like Click&Play for gamez, a art of visual editor with every command you dream inbuild ........ , just a VISUAL DREAMER :mrgreen:

What you think about newbies ? are they professional ?

What you think about my problem ? its easy for you ? or funny for you ?





Num3 thanks for help but i want use API for this . its better for me and smaller .

Thanks.
omid-xp
Enthusiast
Enthusiast
Posts: 119
Joined: Tue Jan 27, 2004 2:17 pm

Post by omid-xp »

This forums have about 1050 user, don't know anybody about this ?

This is very important for me :?
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

I know exist an source code for webcam but it is very big and it not save pic to disk and just view webcam in an window .
If you have some code that shows a webcam picture in a window, it would be very easy to save that picture. Just show that source.

Regards,
El_Choni
omid-xp
Enthusiast
Enthusiast
Posts: 119
Joined: Tue Jan 27, 2004 2:17 pm

Post by omid-xp »

Ok ....


Source

Code: Select all


IncludeFile "avicapincs.pb"

; -----------------------------------------------------------------------------
; D E M O . . .
; -----------------------------------------------------------------------------

OpenAviLibrary ()

If OpenWindow (0, #CW_USEDEFAULT, #CW_USEDEFAULT, 300, 0, #PB_Window_SystemMenu, "Video Capture [initialising...]")

  CreateMenu (0, WindowID ())

  MenuTitle ("&File")
  MenuItem (0, "&About")
  MenuBar ()
  MenuItem (1, "E&xit")

  MenuTitle ("&Control")
  MenuItem (2, "&Start")
  MenuItem (3, "&Display")
  MenuItem (4, "&Format")
  MenuItem (5, "S&ource")
  MenuItem (6, "Co&mpression")
  MenuBar ()
  MenuItem (7, "&Preview")
  SetMenuItemState (0, 7, #TRUE)
  
  ; Create and init capture window, using current window as parent (required)...

  StartCaptureWindow (WindowID ())
  ResizeWindow (capWidth + (GetSystemMetrics_ (#SM_CXBORDER) * 2), capHeight + (GetSystemMetrics_ (#SM_CYBORDER) * 2))

  SetWindowText_ (WindowID (), "Video Capture")
  
  ; [Need to grey out menu items not supported...]

  If dlgSource = 0
    DisableMenuItem (5, #TRUE)
  EndIf

  If dlgFormat = 0
    DisableMenuItem (4, #TRUE)
  EndIf

  If dlgDisplay = 0
    DisableMenuItem (3, #TRUE)
  EndIf
  
  Repeat
  
    e = WaitWindowEvent ()
    
    Select e
    
      Case #PB_Event_CloseWindow
        Goto Quit
                
      Case #PB_EventMenu
      
        Select EventMenuID ()

          Case 0
            MessageRequester ("Video Capture", "Ported to PureBasic by James @ hi-toro.com," + Chr (10) + "from original Visual Basic source by EJ Bantz." + Chr (10) + Chr (10) + "Copyright: None, use and distribute freely.", #MB_ICONINFORMATION | #MB_TASKMODAL)

          Case 1
            Goto Quit

          Case 2
            Start_Click ()

          Case 3
            Display_Click ()
          
          Case 4
            Format_Click ()
            ResizeWindow (capWidth, capHeight)
            
          Case 5
            Source_Click ()
            
          Case 6
            Compression_Click ()
            
          Case 7
            Preview_Click ()
            SetMenuItemState (0, 7, gPreviewStatus)
            
        EndSelect
        
    EndSelect
    
  ForEver
  
EndIf

Quit:

  EndCaptureWindow (0)
  CloseAviLibrary ()
  
End








avicapincs.pb ( included at first source )

Code: Select all


; -----------------------------------------------------------------------------
; ORIGINAL VB TEXT...
; -----------------------------------------------------------------------------

;* Author: E. J. Bantz Jr.
;* Copyright: None, use and distribute freely ...
;* E-Mail: ejbantz@usa.net
;* Web: http://www.inlink.com/~ejbantz

; [ Ported to PureBasic by James @ hi-toro.com ]

; -----------------------------------------------------------------------------
; Some extra PB procedures...
; -----------------------------------------------------------------------------

; Show fatal error message, end program...

Procedure FatalError (error$)
  If error$ = "": error$ = "Undefined error... outta here!": EndIf
  MessageRequester ("Program error -- aborting...", error$, #MB_ICONWARNING | #MB_SYSTEMMODAL)
  End
EndProcedure

; Open avicap32.dll as PB library number 0...

Procedure OpenAviLibrary ()
  If OpenLibrary (0, "avicap32.dll") = 0
    FatalError ("Can't open avicap32.dll!")
  EndIf
EndProcedure

; Close avicap32.dll -- crashes...!

Procedure CloseAviLibrary ()
  ;  CloseLibrary (0) ; Close avicap32.dll -- causes crash/freeze!
EndProcedure

; Function undefined in PB -- uses avicap32.dll to create capture window (returns handle)...

Procedure.l capCreateCaptureWindowA (lpszWindowName$, dwStyle.l, x.l, y.l, nWidth.l, nHeight.b, hWndParent.l, nId.l)
    ProcedureReturn CallFunction (0, "capCreateCaptureWindowA", lpszWindowName$, dwStyle, x, y, nWidth, nHeight, hWndParent, nId)
EndProcedure

; Function undefined in PB -- uses avicap32.dll to get [default?] capture device name. Places
; name and version strings into memory pointers defined when calling...

Procedure.b capGetDriverDescriptionA (wDriver.b, *lpszName, cbName.l, *lpszVer, cbVer.l)
  CallFunction (0, "capGetDriverDescriptionA", wDriver, *lpszName, cbName, *lpszVer, cbVer)
EndProcedure

;// ------------------------------------------------------------------
;//  Windows API Constants / Types / Declarations
;// ------------------------------------------------------------------

#WM_USER = $400
#WS_CHILD = $40000000
#WS_VISIBLE = $10000000
#SWP_NOMOVE = $2
#SWP_NOZORDER = $4
#HWND_BOTTOM = 1

;// ------------------------------------------------------------------
;//  Window Messages  WM_CAP... which can be sent to an AVICAP window
;// ------------------------------------------------------------------

;// Defines start of the message range

#WM_CAP_START = #WM_USER

#WM_CAP_GET_CAPSTREAMPTR = #WM_CAP_START + 1

#WM_CAP_SET_CALLBACK_ERROR = #WM_CAP_START + 2
#WM_CAP_SET_CALLBACK_STATUS = #WM_CAP_START + 3
#WM_CAP_SET_CALLBACK_YIELD = #WM_CAP_START + 4
#WM_CAP_SET_CALLBACK_FRAME = #WM_CAP_START + 5
#WM_CAP_SET_CALLBACK_VIDEOSTREAM = #WM_CAP_START + 6
#WM_CAP_SET_CALLBACK_WAVESTREAM = #WM_CAP_START + 7
#WM_CAP_GET_USER_DATA = #WM_CAP_START + 8
#WM_CAP_SET_USER_DATA = #WM_CAP_START + 9
    
#WM_CAP_DRIVER_CONNECT = #WM_CAP_START + 10
#WM_CAP_DRIVER_DISCONNECT = #WM_CAP_START + 11
#WM_CAP_DRIVER_GET_NAME = #WM_CAP_START + 12
#WM_CAP_DRIVER_GET_VERSION = #WM_CAP_START + 13
#WM_CAP_DRIVER_GET_CAPS = #WM_CAP_START + 14

#WM_CAP_FILE_SET_CAPTURE_FILE = #WM_CAP_START + 20
#WM_CAP_FILE_GET_CAPTURE_FILE = #WM_CAP_START + 21
#WM_CAP_FILE_ALLOCATE = #WM_CAP_START + 22
#WM_CAP_FILE_SAVEAS = #WM_CAP_START + 23
#WM_CAP_FILE_SET_INFOCHUNK = #WM_CAP_START + 24
#WM_CAP_FILE_SAVEDIB = #WM_CAP_START + 25

#WM_CAP_EDIT_COPY = #WM_CAP_START + 30

#WM_CAP_SET_AUDIOFORMAT = #WM_CAP_START + 35
#WM_CAP_GET_AUDIOFORMAT = #WM_CAP_START + 36

#WM_CAP_DLG_VIDEOFORMAT = #WM_CAP_START + 41
#WM_CAP_DLG_VIDEOSOURCE = #WM_CAP_START + 42
#WM_CAP_DLG_VIDEODISPLAY = #WM_CAP_START + 43
#WM_CAP_GET_VIDEOFORMAT = #WM_CAP_START + 44
#WM_CAP_SET_VIDEOFORMAT = #WM_CAP_START + 45
#WM_CAP_DLG_VIDEOCOMPRESSION = #WM_CAP_START + 46

#WM_CAP_SET_PREVIEW = #WM_CAP_START + 50
#WM_CAP_SET_OVERLAY = #WM_CAP_START + 51
#WM_CAP_SET_PREVIEWRATE = #WM_CAP_START + 52
#WM_CAP_SET_SCALE = #WM_CAP_START + 53
#WM_CAP_GET_STATUS = #WM_CAP_START + 54
#WM_CAP_SET_SCROLL = #WM_CAP_START + 55

#WM_CAP_GRAB_FRAME = #WM_CAP_START + 60
#WM_CAP_GRAB_FRAME_NOSTOP = #WM_CAP_START + 61

#WM_CAP_SEQUENCE = #WM_CAP_START + 62
#WM_CAP_SEQUENCE_NOFILE = #WM_CAP_START + 63
#WM_CAP_SET_SEQUENCE_SETUP = #WM_CAP_START + 64
#WM_CAP_GET_SEQUENCE_SETUP = #WM_CAP_START + 65
#WM_CAP_SET_MCI_DEVICE = #WM_CAP_START + 66
#WM_CAP_GET_MCI_DEVICE = #WM_CAP_START + 67
#WM_CAP_STOP = #WM_CAP_START + 68
#WM_CAP_ABORT = #WM_CAP_START + 69

#WM_CAP_SINGLE_FRAME_OPEN = #WM_CAP_START + 70
#WM_CAP_SINGLE_FRAME_CLOSE = #WM_CAP_START + 71
#WM_CAP_SINGLE_FRAME = #WM_CAP_START + 72

#WM_CAP_PAL_OPEN = #WM_CAP_START + 80
#WM_CAP_PAL_SAVE = #WM_CAP_START + 81
#WM_CAP_PAL_PASTE = #WM_CAP_START + 82
#WM_CAP_PAL_AUTOCREATE = #WM_CAP_START + 83
#WM_CAP_PAL_MANUALCREATE = #WM_CAP_START + 84

;// Following added post VFW 1.1
#WM_CAP_SET_CALLBACK_CAPCONTROL = #WM_CAP_START + 85

;// Defines end of the message range
#WM_CAP_END = #WM_CAP_SET_CALLBACK_CAPCONTROL

;// ------------------------------------------------------------------
;//  Structures
;// ------------------------------------------------------------------

Structure CAPDRIVERCAPS
    wDeviceIndex.l ;               // Driver index in system.ini
    fHasOverlay.l ;                // Can device overlay?
    fHasDlgVideoSource.l ;         // Has Video source dlg?
    fHasDlgVideoFormat.l ;         // Has Format dlg?
    fHasDlgVideoDisplay.l ;        // Has External out dlg?
    fCaptureInitialized.l ;        // Driver ready to capture?
    fDriverSuppliesPalettes.l ;    // Can driver make palettes?
    hVideoIn.l ;                   // Driver In channel
    hVideoOut.l ;                  // Driver Out channel
    hVideoExtIn.l ;                // Driver Ext In channel
    hVideoExtOut.l ;               // Driver Ext Out channel
EndStructure

Structure CAPSTATUS
    uiImageWidth.l                    ;// Width of the image
    uiImageHeight.l                   ;// Height of the image
    fLiveWindow.l                     ;// Now Previewing video?
    fOverlayWindow.l                  ;// Now Overlaying video?
    fScale.l                          ;// Scale image to client?
    ptScroll.POINT                    ;// Scroll position
    fUsingDefaultPalette.l            ;// Using default driver palette?
    fAudioHardware.l                  ;// Audio hardware present?
    fCapFileExists.l                  ;// Does capture file exist?
    dwCurrentVideoFrame.l             ;// # of video frames cap;td
    dwCurrentVideoFramesDropped.l     ;// # of video frames dropped
    dwCurrentWaveSamples.l            ;// # of wave samples cap;td
    dwCurrentTimeElapsedMS.l          ;// Elapsed capture duration
    hPalCurrent.l                     ;// Current palette in use
    fCapturingNow.l                   ;// Capture in progress?
    dwReturn.l                        ;// Error value after any operation
    wNumVideoAllocated.l              ;// Actual number of video buffers
    wNumAudioAllocated.l              ;// Actual number of audio buffers
EndStructure

Structure CAPTUREPARMS
    dwRequestMicroSecPerFrame.l       ;// Requested capture rate
    fMakeUserHitOKToCapture.l         ;// Show "Hit OK to cap" dlg?
    wPercentDropForError.l            ;// Give error msg if >  (10%)
    fYield.l                          ;// Capture via background task?
    dwIndexSize.l                     ;// Max index size in frames  (32K)
    wChunkGranularity.l               ;// Junk chunk granularity  (2K)
    fUsingDOSMemory.l                 ;// Use DOS buffers?
    wNumVideoRequested.l              ;// # video buffers, If 0, autocalc
    fCaptureAudio.l                   ;// Capture audio?
    wNumAudioRequested.l              ;// # audio buffers, If 0, autocalc
    vKeyAbort.l                       ;// Virtual key causing abort
    fAbortLeftMouse.l                 ;// Abort on left mouse?
    fAbortRightMouse.l                ;// Abort on right mouse?
    fLimitEnabled.l                   ;// Use wTimeLimit?
    wTimeLimit.l                      ;// Seconds to capture
    fMCIControl.l                     ;// Use MCI video source?
    fStepMCIDevice.l                  ;// Step MCI device?
    dwMCIStartTime.l                  ;// Time to start in MS
    dwMCIStopTime.l                   ;// Time to stop in MS
    fStepCaptureAt2x.l                ;// Perform spatial averaging 2x
    wStepCaptureAverageFrames.l       ;// Temporal average n Frames
    dwAudioBufferSize.l               ;// Size of audio bufs  (0 = default)
    fDisableWriteCache.l              ;// Attempt to disable write cache
EndStructure

Structure CAPINFOCHUNK
    fccInfoID.l                       ;// Chunk ID, "ICOP" for copyright
    lpData.l                          ;// pointer to data
    cbData.l                          ;// size of lpData
EndStructure

Structure VIDEOHDR
    lpData.l ;// address of video buffer
    dwBufferLength.l ;// size, in bytes, of the Data buffer
    dwBytesUsed.l ;// see below
    dwTimeCaptured.l ;// see below
    dwUser.l ;// user-specific data
    dwFlags.l ;// see below
    dwReserved.l[3] ;// reserved; do not use}
EndStructure 

;// ------------------------------------------------------------------
;// String IDs from status and error callbacks
;// ------------------------------------------------------------------

#IDS_CAP_BEGIN = 300              ;/* "Capture Start" */
#IDS_CAP_END = 301                ;/* "Capture End" */

#IDS_CAP_INFO = 401               ;/* "%s" */
#IDS_CAP_OUTOFMEM = 402           ;/* "Out of memory" */
#IDS_CAP_FILEEXISTS = 403         ;/* "File ;%s; exists -- overwrite it?" */
#IDS_CAP_ERRORPALOPEN = 404       ;/* "Error opening palette ;%s;" */
#IDS_CAP_ERRORPALSAVE = 405       ;/* "Error saving palette ;%s;" */
#IDS_CAP_ERRORDIBSAVE = 406       ;/* "Error saving frame ;%s;" */
#IDS_CAP_DEFAVIEXT = 407          ;/* "avi" */
#IDS_CAP_DEFPALEXT = 408          ;/* "pal" */
#IDS_CAP_CANTOPEN = 409           ;/* "Cannot open ;%s;" */
#IDS_CAP_SEQ_MSGSTART = 410       ;/* "Select OK to start capture\nof video sequence\nto %s." */
#IDS_CAP_SEQ_MSGSTOP = 411        ;/* "Hit ESCAPE or click to end capture" */
                
#IDS_CAP_VIDEDITERR = 412         ;/* "An error occurred while trying to run VidEdit." */
#IDS_CAP_READONLYFILE = 413       ;/* "The file ;%s; is a read-only file." */
#IDS_CAP_WRITEERROR = 414         ;/* "Unable to write to file ;%s;.\nDisk may be full." */
#IDS_CAP_NODISKSPACE = 415        ;/* "There is no space to create a capture file on the specified device." */
#IDS_CAP_SETFILESIZE = 416        ;/* "Set File Size" */
#IDS_CAP_SAVEASPERCENT = 417      ;/* "SaveAs: %2ld%%  Hit Escape to abort." */
                
#IDS_CAP_DRIVER_ERROR = 418       ;/* Driver specific error message */

#IDS_CAP_WAVE_OPEN_ERROR = 419    ;/* "Error: Cannot open the wave input device.\nCheck sample size, frequency, and channels." */
#IDS_CAP_WAVE_ALLOC_ERROR = 420   ;/* "Error: Out of memory for wave buffers." */
#IDS_CAP_WAVE_PREPARE_ERROR = 421 ;/* "Error: Cannot prepare wave buffers." */
#IDS_CAP_WAVE_ADD_ERROR = 422     ;/* "Error: Cannot add wave buffers." */
#IDS_CAP_WAVE_SIZE_ERROR = 423    ;/* "Error: Bad wave size." */
                
#IDS_CAP_VIDEO_OPEN_ERROR = 424   ;/* "Error: Cannot open the video input device." */
#IDS_CAP_VIDEO_ALLOC_ERROR = 425  ;/* "Error: Out of memory for video buffers." */
#IDS_CAP_VIDEO_PREPARE_ERROR = 426 ;/* "Error: Cannot prepare video buffers." */
#IDS_CAP_VIDEO_ADD_ERROR = 427    ;/* "Error: Cannot add video buffers." */
#IDS_CAP_VIDEO_SIZE_ERROR = 428   ;/* "Error: Bad video size." */
                
#IDS_CAP_FILE_OPEN_ERROR = 429    ;/* "Error: Cannot open capture file." */
#IDS_CAP_FILE_WRITE_ERROR = 430   ;/* "Error: Cannot write to capture file.  Disk may be full." */
#IDS_CAP_RECORDING_ERROR = 431    ;/* "Error: Cannot write to capture file.  Data rate too high or disk full." */
#IDS_CAP_RECORDING_ERROR2 = 432   ;/* "Error while recording" */
#IDS_CAP_AVI_INIT_ERROR = 433     ;/* "Error: Unable to initialize for capture." */
#IDS_CAP_NO_FRAME_CAP_ERROR = 434 ;/* "Warning: No frames captured.\nConfirm that vertical sync interrupts\nare configured and enabled." */
#IDS_CAP_NO_PALETTE_WARN = 435    ;/* "Warning: Using default palette." */
#IDS_CAP_MCI_CONTROL_ERROR = 436  ;/* "Error: Unable to access MCI device." */
#IDS_CAP_MCI_CANT_STEP_ERROR = 437 ;/* "Error: Unable to step MCI device." */
#IDS_CAP_NO_AUDIO_CAP_ERROR = 438 ;/* "Error: No audio data captured.\nCheck audio card settings." */
#IDS_CAP_AVI_DRAWDIB_ERROR = 439  ;/* "Error: Unable to draw this data format." */
#IDS_CAP_COMPRESSOR_ERROR = 440   ;/* "Error: Unable to initialize compressor." */
#IDS_CAP_AUDIO_DROP_ERROR = 441   ;/* "Error: Audio data was lost during capture, reduce capture rate." */
                
;/* status string IDs */

#IDS_CAP_STAT_LIVE_MODE = 500      ;/* "Live window" */
#IDS_CAP_STAT_OVERLAY_MODE = 501   ;/* "Overlay window" */
#IDS_CAP_STAT_CAP_INIT = 502       ;/* "Setting up for capture - Please wait" */
#IDS_CAP_STAT_CAP_FINI = 503       ;/* "Finished capture, now writing frame %ld" */
#IDS_CAP_STAT_PALETTE_BUILD = 504  ;/* "Building palette map" */
#IDS_CAP_STAT_OPTPAL_BUILD = 505   ;/* "Computing optimal palette" */
#IDS_CAP_STAT_I_FRAMES = 506       ;/* "%d frames" */
#IDS_CAP_STAT_L_FRAMES = 507       ;/* "%ld frames" */
#IDS_CAP_STAT_CAP_L_FRAMES = 508   ;/* "Captured %ld frames" */
#IDS_CAP_STAT_CAP_AUDIO = 509      ;/* "Capturing audio" */
#IDS_CAP_STAT_VIDEOCURRENT = 510   ;/* "Captured %ld frames  (%ld dropped) %d.%03d sec." */
#IDS_CAP_STAT_VIDEOAUDIO = 511     ;/* "Captured %d.%03d sec.  %ld frames  (%ld dropped)  (%d.%03d fps).  %ld audio bytes  (%d,%03d sps)" */
#IDS_CAP_STAT_VIDEOONLY = 512      ;/* "Captured %d.%03d sec.  %ld frames  (%ld dropped)  (%d.%03d fps)" */

Procedure.b capSetCallbackOnError (lwnd.l, lpProc.l)
   capSetCallbackOnError = SendMessage_ (lwnd, #WM_CAP_SET_CALLBACK_ERROR, 0, lpProc)
EndProcedure

Procedure.b capSetCallbackOnStatus (lwnd.l, lpProc.l)
   capSetCallbackOnStatus = SendMessage_ (lwnd, #WM_CAP_SET_CALLBACK_STATUS, 0, lpProc)
EndProcedure

Procedure.b capSetCallbackOnYield (lwnd.l, lpProc.l)
   capSetCallbackOnYield = SendMessage_ (lwnd, #WM_CAP_SET_CALLBACK_YIELD, 0, lpProc)
EndProcedure

Procedure.b capSetCallbackOnFrame (lwnd.l, lpProc.l)
   capSetCallbackOnFrame = SendMessage_ (lwnd, #WM_CAP_SET_CALLBACK_FRAME, 0, lpProc)
EndProcedure

Procedure.b capSetCallbackOnVideoStream (lwnd.l, lpProc.l)
   capSetCallbackOnVideoStream = SendMessage_ (lwnd, #WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, lpProc)
EndProcedure

Procedure.b capSetCallbackOnWaveStream (lwnd.l, lpProc.l)
   capSetCallbackOnWaveStream = SendMessage_ (lwnd, #WM_CAP_SET_CALLBACK_WAVESTREAM, 0, lpProc)
EndProcedure

Procedure.b capSetCallbackOnCapControl (lwnd.l, lpProc.l)
   capSetCallbackOnCapControl = SendMessage_ (lwnd, #WM_CAP_SET_CALLBACK_CAPCONTROL, 0, lpProc)
EndProcedure

Procedure.b capSetUserData (lwnd.l, lUser.l)
   capSetUserData = SendMessage_ (lwnd, #WM_CAP_SET_USER_DATA, 0, lUser)
EndProcedure

Procedure.l capGetUserData (lwnd.l)
   capGetUserData = SendMessage_ (lwnd, #WM_CAP_GET_USER_DATA, 0, 0)
EndProcedure

Procedure.b capDriverConnect (lwnd.l, i.b)
   capDriverConnect = SendMessage_ (lwnd, #WM_CAP_DRIVER_CONNECT, i, 0)
EndProcedure

Procedure.b capDriverDisconnect (lwnd.l)
   capDriverDisconnect = SendMessage_ (lwnd, #WM_CAP_DRIVER_DISCONNECT, 0, 0)
EndProcedure

Procedure.b capDriverGetName (lwnd.l, szName.l, wSize.b)
   capDriverGetName = SendMessage_ (lwnd, YOURCONSTANTMESSAGE, wSize, szName)
EndProcedure

Procedure.b capDriverGetVersion (lwnd.l, szVer.l, wSize.b)
   capDriverGetVersion = SendMessage_ (lwnd, #WM_CAP_DRIVER_GET_VERSION, wSize, szVer)
EndProcedure

Procedure.b capDriverGetCaps (lwnd.l, s.l, wSize.b)
   capDriverGetCaps = SendMessage_ (lwnd, #WM_CAP_DRIVER_GET_CAPS, wSize, s)
EndProcedure

Procedure.b capFileSetCaptureFile (lwnd.l, szName.l)
   capFileSetCaptureFile = SendMessage_ (lwnd, #WM_CAP_FILE_SET_CAPTURE_FILE, 0, szName)
EndProcedure

Procedure.b capFileGetCaptureFile (lwnd.l, szName.l, wSize.b)
   capFileGetCaptureFile = SendMessage_ (lwnd, #WM_CAP_FILE_SET_CAPTURE_FILE, wSize, szName)
EndProcedure

Procedure.b capFileAlloc (lwnd.l, dwSize.l)
   capFileAlloc = SendMessage_ (lwnd, #WM_CAP_FILE_ALLOCATE, 0, dwSize)
EndProcedure

Procedure.b capFileSaveAs (lwnd.l, szName.l)
   capFileSaveAs = SendMessage_ (lwnd, #WM_CAP_FILE_SAVEAS, 0, szName)
EndProcedure

Procedure.b capFileSetInfoChunk (lwnd.l, lpInfoChunk.l)
   capFileSetInfoChunk = SendMessage_ (lwnd, #WM_CAP_FILE_SET_INFOCHUNK, 0, lpInfoChunk)
EndProcedure

Procedure.b capFileSaveDIB (lwnd.l, szName.l)
   capFileSaveDIB = SendMessage_ (lwnd, #WM_CAP_FILE_SAVEDIB, 0, szName)
EndProcedure

Procedure.b capEditCopy (lwnd.l)
   capEditCopy = SendMessage_ (lwnd, #WM_CAP_EDIT_COPY, 0, 0)
EndProcedure

Procedure.b capSetAudioFormat (lwnd.l, s.l, wSize.b)
   capSetAudioFormat = SendMessage_ (lwnd, #WM_CAP_SET_AUDIOFORMAT, wSize, s)
EndProcedure

Procedure.l capGetAudioFormat (lwnd.l, s.l, wSize.b)
   capGetAudioFormat = SendMessage_ (lwnd, #WM_CAP_GET_AUDIOFORMAT, wSize, s)
EndProcedure

Procedure.l capGetAudioFormatSize (lwnd.l)
   capGetAudioFormatSize = SendMessage_ (lwnd, #WM_CAP_GET_AUDIOFORMAT, 0, 0)
EndProcedure

Procedure.b capDlgVideoFormat (lwnd.l)
   capDlgVideoFormat = SendMessage_ (lwnd, #WM_CAP_DLG_VIDEOFORMAT, 0, 0)
EndProcedure

Procedure.b capDlgVideoSource (lwnd.l)
   capDlgVideoSource = SendMessage_ (lwnd, #WM_CAP_DLG_VIDEOSOURCE, 0, 0)
EndProcedure

Procedure.b capDlgVideoDisplay (lwnd.l)
   capDlgVideoDisplay = SendMessage_ (lwnd, #WM_CAP_DLG_VIDEODISPLAY, 0, 0)
EndProcedure

Procedure.b capDlgVideoCompression (lwnd.l)
   capDlgVideoCompression = SendMessage_ (lwnd, #WM_CAP_DLG_VIDEOCOMPRESSION, 0, 0)
EndProcedure

Procedure.l capGetVideoFormat (lwnd.l, s.l, wSize.b)
   capGetVideoFormat = SendMessage_ (lwnd, #WM_CAP_GET_VIDEOFORMAT, wSize, s)
EndProcedure

Procedure.l capGetVideoFormatSize (lwnd.l)
   capGetVideoFormatSize = SendMessage_ (lwnd, #WM_CAP_GET_VIDEOFORMAT, 0, 0)
EndProcedure

Procedure.b capSetVideoFormat (lwnd.l, s.l, wSize.b)
   capSetVideoFormat = SendMessage_ (lwnd, #WM_CAP_SET_VIDEOFORMAT, wSize, s)
EndProcedure

Procedure.b capPreview (lwnd.l, f.b)
   capPreview = SendMessage_ (lwnd, #WM_CAP_SET_PREVIEW, f, 0)
EndProcedure

Procedure.b capPreviewRate (lwnd.l, wMS.b)
   capPreviewRate = SendMessage_ (lwnd, #WM_CAP_SET_PREVIEWRATE, wMS, 0)
EndProcedure

Procedure.b capOverlay (lwnd.l, f.b)
   capOverlay = SendMessage_ (lwnd, #WM_CAP_SET_OVERLAY, f, 0)
EndProcedure

Procedure.b capPreviewScale (lwnd.l, f.b)
   capPreviewScale = SendMessage_ (lwnd, #WM_CAP_SET_SCALE, f, 0)
EndProcedure

Procedure.b capGetStatus (lwnd.l, s.l, wSize.b)
   capGetStatus = SendMessage_ (lwnd, #WM_CAP_GET_STATUS, wSize, s)
EndProcedure

Procedure.b capSetScrollPos (lwnd.l, lpP.l)
   capSetScrollPos = SendMessage_ (lwnd, #WM_CAP_SET_SCROLL, 0, lpP)
EndProcedure

Procedure.b capGrabFrame (lwnd.l)
   capGrabFrame = SendMessage_ (lwnd, #WM_CAP_GRAB_FRAME, 0, 0)
EndProcedure

Procedure.b capGrabFrameNoStop (lwnd.l)
   capGrabFrameNoStop = SendMessage_ (lwnd, #WM_CAP_GRAB_FRAME_NOSTOP, 0, 0)
EndProcedure

Procedure.b capCaptureSequence (lwnd.l)
   capCaptureSequence = SendMessage_ (lwnd, #WM_CAP_SEQUENCE, 0, 0)
EndProcedure

Procedure.b capCaptureSequenceNoFile (lwnd.l)
   capCaptureSequenceNoFile = SendMessage_ (lwnd, #WM_CAP_SEQUENCE_NOFILE, 0, 0)
EndProcedure

Procedure.b capCaptureStop (lwnd.l)
   capCaptureStop = SendMessage_ (lwnd, #WM_CAP_STOP, 0, 0)
EndProcedure

Procedure.b capCaptureAbort (lwnd.l)
   capCaptureAbort = SendMessage_ (lwnd, #WM_CAP_ABORT, 0, 0)
EndProcedure

Procedure.b capCaptureSingleFrameOpen (lwnd.l)
   capCaptureSingleFrameOpen = SendMessage_ (lwnd, #WM_CAP_SINGLE_FRAME_OPEN, 0, 0)
EndProcedure

Procedure.b capCaptureSingleFrameClose (lwnd.l)
   capCaptureSingleFrameClose = SendMessage_ (lwnd, #WM_CAP_SINGLE_FRAME_CLOSE, 0, 0)
EndProcedure

Procedure.b capCaptureSingleFrame (lwnd.l)
   capCaptureSingleFrame = SendMessage_ (lwnd, #WM_CAP_SINGLE_FRAME, 0, 0)
EndProcedure

Procedure.b capCaptureGetSetup (lwnd.l, s.l, wSize.b)
   capCaptureGetSetup = SendMessage_ (lwnd, #WM_CAP_GET_SEQUENCE_SETUP, wSize, s)
EndProcedure

Procedure.b capCaptureSetSetup (lwnd.l, s.l, wSize.b)
   capCaptureSetSetup = SendMessage_ (lwnd, #WM_CAP_SET_SEQUENCE_SETUP, wSize, s)
EndProcedure

Procedure.b capSetMCIDeviceName (lwnd.l, szName.l)
   capSetMCIDeviceName = SendMessage_ (lwnd, #WM_CAP_SET_MCI_DEVICE, 0, szName)
EndProcedure

Procedure.b capGetMCIDeviceName (lwnd.l, szName.l, wSize.b)
   capGetMCIDeviceName = SendMessage_ (lwnd, #WM_CAP_GET_MCI_DEVICE, wSize, szName)
EndProcedure

Procedure.b capPaletteOpen (lwnd.l, szName.l)
   capPaletteOpen = SendMessage_ (lwnd, #WM_CAP_PAL_OPEN, 0, szName)
EndProcedure

Procedure.b capPaletteSave (lwnd.l, szName.l)
   capPaletteSave = SendMessage_ (lwnd, #WM_CAP_PAL_SAVE, 0, szName)
EndProcedure

Procedure.b capPalettePaste (lwnd.l)
   capPalettePaste = SendMessage_ (lwnd, #WM_CAP_PAL_PASTE, 0, 0)
EndProcedure

Procedure.b capPaletteAuto (lwnd.l, iFrames.b, iColor.l)
   capPaletteAuto = SendMessage_ (lwnd, #WM_CAP_PAL_AUTOCREATE, iFrames, iColors)
EndProcedure

Procedure.b capPaletteManual (lwnd.l, fGrab.b, iColors.l)
   capPaletteManual = SendMessage_ (lwnd, #WM_CAP_PAL_MANUALCREATE, fGrab, iColors)
EndProcedure

Procedure.l MyFrameCallback (lwnd.l, lpVHdr.l)
    DefType.VIDEOHDR VideoHeader
    ;//Fill VideoHeader with data at lpVHdr
    RtlMoveMemory_ (@VideoHeader, lpVHdr, SizeOf (VIDEOHDR))
    ;// Make room for data
    Dim VideoData (VideoHeader\dwBytesUsed)
    ;//Copy data into the array
    RtlMoveMemory_ (@VideoData (0), VideoHeader\lpData, VideoHeader\dwBytesUsed)
EndProcedure

Procedure.l MyYieldCallback (lwnd.l)
;    Debug.Print "Yield"
EndProcedure

Procedure.l MyErrorCallback (lwnd.l, iID.l, ipstrStatusText.l)
    
    If iID = 0
      ProcedureReturn 0
    EndIf
    
;    DefType.s sStatusText
 ;   DefType.s usStatusText
    
    ;Convert the Pointer to a real VB String
 ;   sStatusText = Space$ (255)                                      ;// Make room for message
    
    ;lStrCpy StrPtr (sStatusText), ipstrStatusText                       ;// Copy message into String
    
  ;  PokeS (@sStatusText, PeekS (ipstrStatusText))
    
;    sStatusText = Left (sStatusText, InStr (sStatusText, Chr$ (0)) - 1)  ;// Only look at left of null
    ; ^^^ Not needed? PB should sort that, I think...
    
   ; usStatusText = StrConv (sStatusText, vbUnicode)                     ;// Convert Unicode
            
    ;Debug.Print "Error: ", usStatusText, iID

EndProcedure

Procedure.l MyStatusCallback (lwnd.l, iID.l, ipstrStatusText.l)
  If iID = 0
    ProcedureReturn 0
  EndIf
  ;    Dim sStatusText As String
  ;    Dim usStatusText As String

  ;    ;// Convert the Pointer to a real VB String
  ;    sStatusText = String$ (255, 0)                                      ;// Make room for message
  ;    lStrCpy StrPtr (sStatusText), ipstrStatusText                       ;// Copy message into String
  ;    sStatusText = Left$ (sStatusText, InStr (sStatusText, Chr$ (0)) - 1)  ;// Only look at left of null
  ;    usStatusText = StrConv (sStatusText, vbUnicode)                     ;// Convert Unicode

  ;    Debug.Print "Status: ", usStatusText, iID
EndProcedure

Procedure.l MyVideoStreamCallback (lwnd.l, lpVHdr.l)
  ; Beep  ;// Replace this with your code!
EndProcedure

Procedure.l MyWaveStreamCallback (lwnd.l, lpVHdr.l)
  ; Debug.Print "WaveStream"
EndProcedure

Global gPreviewStatus: gPreviewStatus = #TRUE ; Status of 'Preview' option...

Global lwndC.l ;      ' Handle to the Capture Windows
Global lNFrames.l ;  ' Number of frames captured

Global dlgSource.l: dlgSource = #True
Global dlgFormat.l: dlgFormat = #True
Global dlgDisplay.l: dlgDisplay = #True

Global capWidth, capHeight

Procedure ResizeCaptureWindow (lwnd.l)
  DefType.CAPSTATUS capstat
  ;// Get the capture window attributes .. width and height
  capGetStatus (lwnd, @capstat, SizeOf (CAPSTATUS))
  ;// Resize the capture window to the capture sizes
  SetWindowPos_ (lwnd, #HWND_BOTTOM, 0, 0, capstat\uiImageWidth, capstat\uiImageHeight, #SWP_NOMOVE | #SWP_NOZORDER)
  capWidth = capstat\uiImageWidth
  capHeight = capstat\uiImageHeight
EndProcedure

Procedure StartCaptureWindow (parentwindow.l)

  *lpszName = AllocateMemory (100)
  *lpszVer = AllocateMemory (100)

  DefType.CAPDRIVERCAPS Caps

  ;//Create Capture Window
  capGetDriverDescriptionA (0, lpszName, 100, lpszVer, 100)  ;// Retrieves driver info

  name$ = PeekS (lpszName)

  lwndC = capCreateCaptureWindowA (name$, #WS_CHILD | #WS_VISIBLE, 0, 0, 160, 120, parentwindow, 0)

  ;// Connect the capture window to the driver
  capDriverConnect (lwndC, 0)

  ;// Get the capabilities of the capture driver
  capDriverGetCaps (lwndC, @Caps, SizeOf (CAPDRIVERCAPS))

  ;// If the capture driver does not support a dialog, grey it out
  ;// in the menu bar.

  If Caps\fHasDlgVideoSource = 0
    dlgSource = False
  EndIf

  If Caps\fHasDlgVideoFormat = 0
    dlgFormat = False
  EndIf

  If Caps\fHasDlgVideoDisplay = 0
    dlgDisplay = False
  EndIf

  ;// Set the video stream callback function
  capSetCallbackOnVideoStream (lwndC, @MyVideoStreamCallback ())

  capSetCallbackOnFrame (lwndC, @MyFrameCallback ())

  ;// Set the preview rate in milliseconds
  capPreviewRate (lwndC, 66)

  ;// Start previewing the image from the camera
  capPreview (lwndC, #True)

  ;// Resize the capture window to show the whole image
  ResizeCaptureWindow (lwndC)

EndProcedure

Procedure EndCaptureWindow (Cancel.b)
  ;// Disable all callbacks
  capSetCallbackOnError (lwndC, #Null)
  capSetCallbackOnStatus (lwndC, #Null)
  capSetCallbackOnYield (lwndC, #Null)
  capSetCallbackOnFrame (lwndC, #Null)
  capSetCallbackOnVideoStream (lwndC, #Null)
  capSetCallbackOnWaveStream (lwndC, #Null)
  capSetCallbackOnCapControl (lwndC, #Null)
EndProcedure

Procedure Compression_Click ()
  capDlgVideoCompression (lwndC)
EndProcedure

Procedure Display_Click ()
  capDlgVideoDisplay (lwndC)
EndProcedure

Procedure Format_Click ()
  capDlgVideoFormat (lwndC)
  ResizeCaptureWindow (lwndC)
EndProcedure

Procedure Preview_Click ()
  If gPreviewStatus
    gPreviewStatus = #False
  Else
    gPreviewStatus = #True
  EndIf
  capPreview (lwndC, gPreviewStatus)
EndProcedure

Procedure Source_Click ()
  capDlgVideoSource (lwndC)
EndProcedure

Procedure Start_Click ()
  lNFrames = 0
  capCaptureSequenceNoFile (lwndC)
EndProcedure





avicapincs.pb include very Procedure, i don't know must use what .
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

omid-xp: What kind of trojan/virus/spyware are you writing anyway? Is my inbox going to be filled with emails from some new worm you're working on? :-)
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

Working on it but won't be until tomorrow. In the mean time you might want to check against PB's syntax, eg,

Code: Select all

  *lpszName = AllocateMemory (100)
  *lpszVer = AllocateMemory (100)

  DefType.CAPDRIVERCAPS Caps

  ;//Create Capture Window
  capGetDriverDescriptionA (0, lpszName, 100, lpszVer, 100)  ;// Retrieves driver info
...use of "*" wrong. Could just use "Name.s = Space(100)" and then "capGetDriverDescriptionA (0, lpszName, ..."

PS: I'm still on 3.81 so you may have to edit further for 3.9
Hi-Toro
Enthusiast
Enthusiast
Posts: 269
Joined: Sat Apr 26, 2003 3:23 pm

Post by Hi-Toro »

I'd normally help (I posted that code), but strongly believe you are almost certainly writing a highly destructive and/or intrusive program, if not an actual virus.
James Boyd
http://www.hi-toro.com/
Death to the Pixies!
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

This should be more than a virus, it seems to take the roadmad of an app able to capture your video .. not sure what omid-xp wants to do, but the stuff he is integrated should allow to catch webcam for posting it in an email ...

It could become either nice or bad depending on its way to market it or to place as a complex worm.

Should he tell us but definitely he lies or kids us by asking for newby code and posting tons of procs containing deep calls.

:!:
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

he could be simply copy / pasting stuff... does the code look familiar or did he write it himself?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

am not sure but as posts were exchanged I guess he is not a good coder. This is probably not a sole guy but probably an alias to several people trying to adapt stuff they could not make running well in another way.

Not sure. I have my opinion but just an opinion. I just would like to know the IP addresses used and I would be get informed definitely for sure.

Rgrds
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

Am I missing something here? Serious question, no sarcasm intended. I see a chunk of VB code converted by Hi-Toro and a newbie trying to make use of it. I see nothing to indicate that it is anything but an example of how to interface with a video capture device. No suspicious code, no email mechanism, so what's the problem? Like I said, serious question in case I am misunderstanding something somewhere :?
omid-xp
Enthusiast
Enthusiast
Posts: 119
Joined: Tue Jan 27, 2004 2:17 pm

Post by omid-xp »

Please read this :

viewtopic.php?p=57129#57129
Post Reply