Einzelnen Beitrag anzeigen

taktaky
(Gast)

n/a Beiträge
 
#9

Re: Bild aus Webcam, bekomme ich Schwarz!

  Alt 19. Sep 2007, 16:25
Zitat von DeddyH:
Benenn die Variable mal um.
welche Variable ?
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, clipbrd;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Panel1: TPanel;
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  const
WM_CAP_DRIVER_CONNECT = WM_USER + 10;
WM_CAP_EDIT_COPY = WM_USER + 30;
WM_CAP_SET_PREVIEW = WM_USER + 50;
WM_CAP_SET_OVERLAY = WM_USER + 51;
WM_CAP_SET_PREVIEWRATE = WM_USER + 52;

implementation

{$R *.DFM}
function capCreateCaptureWindow(lpszWindowName: LPCSTR;
dwStyle: DWORD;
x, y,
nWidth,
nHeight: integer;
hwndParent: HWND;
nID: integer): HWND; stdcall;
external 'AVICAP32.DLLname 'capCreateCaptureWindowA';

procedure TForm1.FormCreate(Sender: TObject);
begin
handle := capCreateCaptureWindow('Video',ws_child+ws_visible, 0,
0, 320, 240, Panel1.Handle, 1); //Wie du siehst, brauchst du ein Panel in diesem Beispiel ;-)
SendMessage(handle, WM_CAP_DRIVER_CONNECT, 0, 0);
SendMessage(handle, WM_CAP_SET_PREVIEWRATE, 30, 0);
sendMessage(handle, WM_CAP_SET_OVERLAY, 1, 0);
SendMessage(handle, wm_cap_set_preview, 1, 0);

//Das sollte das Problem mit der roten Farbe lösen
Image1.Picture.Bitmap.Pixelformat := pf24Bit;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
//Bild in Zwischenablage kopieren
SendMessage(handle, WM_CAP_EDIT_COPY, 1, 0 );
Image1.Picture.Bitmap.LoadFromClipboardFormat(cf_BitMap,ClipBoard.GetAsHandle(cf_Bitmap),0);

end;

end.
  Mit Zitat antworten Zitat