Hi Nigel,
yes, the code works correctly when TImageEnView object is on form. the following code contain 2 imageENView, imageENView1 has its corresponding object on the form and grabs frames correctly and imageENView2 does not have a related component and is create as a variable but never enter into "OnDshowNewFrame" event.
var
ImageEnView2 : TImageEnView;
-----------------------------------------------------------------------------------
ImageEnView2 := TImageEnView.Create(nil);
ImageEnView2.IO.Create(ImageEnView2);
ImageEnView2.IO.AsyncMode := True;
ImageEnView2.IO.DShowParams.EnableSampleGrabber := true;
MyClass.Create;
-----------------------------------------------------------------------------------
ImageEnView1.OnDShowNewFrame := MyClass.ImageEnView1DShowNewFrame;
//ImageEnView2.OnDShowNewFrame := MyClass.ImageEnView2DShowNewFrame;
-----------------------------------------------------------------------------------
if (not ImageEnView1.IO.DShowParams.Connected) then
begin
ImageEnView1.IO.DShowParams.SetVideoInput(0 , 0 , w , h , f);
ImageEnView1.IO.DShowParams.EnableSampleGrabber := true;
ImageEnView1.IO.DShowParams.Connect;
end;
if (not ImageEnView2.IO.DShowParams.Connected) then
begin
ImageEnView2.IO.DShowParams.SetVideoInput(0 , 1 , w , h , f);
ImageEnView2.IO.DShowParams.EnableSampleGrabber := true;
ImageEnView2.IO.DShowParams.Connect;
end;
ImageEnView1.IO.DShowParams.GetCurrentVideoFormat(w, h, f);
ImageEnView1.IO.DShowParams.Run;
ImageEnView2.IO.DShowParams.GetCurrentVideoFormat(w, h, f);
ImageEnView2.IO.DShowParams.Run;
-----------------------------------------------------------------------------------
class procedure MyClass.ImageEnView2DShowNewFrame(Sender: TObject);
begin
ImageEnView2.IO.DShowParams.GetSample(ImageEnView2.IEBitmap);
Form1.Image2.Picture.Bitmap.Assign(ImageEnView2.Bitmap);
end;
class procedure MyClass.ImageEnView1DShowNewFrame(Sender: TObject);
begin
ImageEnView1.IO.DShowParams.GetSample(ImageEnView1.IEBitmap);
Form1.Image1.Picture.Bitmap.Assign(ImageEnView1.Bitmap);
end;
and when i show the owner name of imageEnView2.Io.Ownar.name the ownar name is empty while in ImageEnView2.IO.Create(ImageEnView2); the ImageEnView2 assigned as ownar of ImageEnView2.IO...