Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   OOP (https://www.clubdelphi.com/foros/forumdisplay.php?f=5)
-   -   componente para capturar foto (https://www.clubdelphi.com/foros/showthread.php?t=61974)

CoCaInE 28-11-2008 17:47:34

componente para capturar foto
 
Buenas colegas me gustaria que me ayudaran con alguna duda, existe algun componente con la cual pueda capturar una foto de una camara web utilizando delphi 2009. :)

cHackAll 29-11-2008 17:31:11

Código Delphi [-]
function capCreateCaptureWindowA(lpWindowName: PChar; dwStyle, X, Y, nWidth, nHeight, hWnd, nID: Integer): Cardinal; stdcall external 'avicap32';
function capGetDriverDescriptionA(wDriverIndex: Word; lpszName: PChar; cbName: Cardinal; lpszVer: PChar; cbVer: Cardinal): LongBool; stdcall external 'avicap32';

function GetCapture(lpszName: PChar; hWnd: Integer): Cardinal;
var
 DeviceName: array [0..31] of Char;
 Rect: TRect;
begin
 Result := 0;
 repeat if capGetDriverDescriptionA(Result, @DeviceName, SizeOf(DeviceName), nil, 0) and (lstrcmp(@DeviceName, lpszName) = 0) then
  begin GetClientRect(hWnd, Rect);
   hWnd := capCreateCaptureWindowA('cap.wnd', WS_CHILD or WS_VISIBLE, 0, 0, Rect.Right, Rect.Bottom, hWnd, 0);
   if hWnd <> 0 then
    begin
     SendMessage(hWnd, WM_USER + 10{WM_CAP_DRIVER_CONNECT}, Result, 0);
     SendMessage(hWnd, WM_USER + 53{WM_CAP_SET_SCALE}, 1, 0);
     SendMessage(hWnd, WM_USER + 52{WM_CAP_SET_PREVIEWRATE}, 33, 0);
     SendMessage(hWnd, WM_USER + 51{WM_CAP_SET_OVERLAY}, 0, 0);
     SendMessage(hWnd, WM_USER + 50{WM_CAP_SET_PREVIEW}, 1, 0);
     ShowWindow(hWnd, SW_SHOW);
    end;
   Result := hWnd;
   Exit;
  end;
  Inc(Result);
 until Result = 10;
 Result := 0;
end;

procedure Capture(const hCapture: Cardinal; const lpFileName: PChar);
begin
 SendMessage(hCapture, WM_USER + 60{WM_CAP_GRAB_FRAME}, 0, 0);
 SendMessage(hCapture, WM_USER + 25{WM_CAP_FILE_SAVEDIB}, 0, Integer(lpFileName));
 SendMessage(hCapture, WM_USER + 50{WM_CAP_SET_PREVIEW}, 1, 0); // Restart preview
end;

var hCapture: Cardinal;

procedure TForm1.Button1Click(Sender: TObject);
begin
 Capture(hCapture, 'c:\archivo.bmp');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 hCapture := GetCapture('Creative WebCam NX Pro (VFW)', Panel1.Handle);
end;

CoCaInE 30-11-2008 13:24:25

No me funciona
 
Eh puesto el codigo tal como me lo has indicado utilizando un panel y un boton y no me funciona me podrias dar otra manito:)

Caral 30-11-2008 13:39:48

Hola
Tengo entendido que aqui se pone la marca o modelo de la cámara web:
Código Delphi [-]
procedure TForm1.FormCreate(Sender: TObject);
begin
 hCapture := GetCapture('Creative WebCam NX Pro (VFW)', Panel1.Handle);
end;
La que usas es de esa misma marca o modelo??.
Saludos


La franja horaria es GMT +2. Ahora son las 10:05:23.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi