Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Your program works for me on Win7 32bits with D2010</strong>.</p> <p>What it does though is raising an exception: </p> <pre><code>--------------------------- Project WebCamTest.exe raised exception class EFCreateError with message 'Cannot create file "c:\webcam.jpg". Access is denied'. --------------------------- </code></pre> <p>which can be corrected by changing</p> <pre><code>FJpeg.SaveToFile('c:\webcam.jpg'); </code></pre> <p>to</p> <pre><code>FJpeg.SaveToFile(TPath.GetTempPath + '\webcam.jpg'); </code></pre> <p>And also, it does not display the whole available image, you'd have to enlarge your Panel, recenter or shrink the webcam output.</p> <p><strong>Update with some code modifications that would make it work per your comments...</strong></p> <pre><code> // introducing the RGB array and a buffer TVideoArray = array[1..PICHEIGHT] of array[1..PICWIDTH] of TRGBTriple; PVideoArray = ^TVideoArray; TForm1 = class(TForm) [...] FBuf24_1: TVideoArray; [...] function FrameCallbackFunction(AHandle: hWnd; VIDEOHDR: TVideoHDRPtr): bool; stdcall; var I: integer; begin result:= true; with form1 do begin try if ConvertCodecToRGB(FCodec, VideoHDR^.lpData, @FBuf2, PICWIDTH, PICHEIGHT) then begin for I:= 1 to PICHEIGHT do FBuf1[I]:= FBuf2[PICHEIGHT- (I- 1)]; SetBitmapBits(FBitmap.Handle, PICWIDTH* PICHEIGHT* SizeOf(DWord), @FBuf1); end else begin // assume RGB for I:= 1 to PICHEIGHT do FBuf24_1[I] := PVideoArray(VideoHDR^.lpData)^[PICHEIGHT-I+1]; SetBitmapBits(FBitmap.Handle, PICWIDTH* PICHEIGHT* SizeOf(RGBTriple), @FBuf24_1); end; [...] </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload