AVICAP32.DLL 用着个抓不到图呀

比特灵 2017-11-23 10:21:43
网上很多很多的帖子,都差不多,但是我试了几个都不能抓图呀,也不能录像,谁有成功过指点下啊,谢谢。。。
...全文
296 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lyhoo163 2017-11-24
  • 打赏
  • 举报
回复
比特灵 2017-11-24
  • 打赏
  • 举报
回复
[dcc32 Error] Unit1.pas(50): E2003 Undeclared identifier: 'SampleGrabber'
比特灵 2017-11-24
  • 打赏
  • 举报
回复
多谢LS回复,尝试使用DSPACK,遇到SampleGrabber 未定义的错误,如何解决呢?谢谢
lyhoo163 2017-11-24
  • 打赏
  • 举报
回复
未用过AVICAP32.DLL,建议使用DSPack功能比较多,例子也多。
比特灵 2017-11-24
  • 打赏
  • 举报
回复
上面的问题已经解决,但是忘记怎么解决的了,贴个代码吧:

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, DSUtil, DirectShow9, DSPack,
  Vcl.StdCtrls, DXSUtil, Vcl.ExtCtrls,
  ComCtrls;

type
  TForm1 = class(TForm)
    FilterGraph1: TFilterGraph;
    VideoWindow1: TVideoWindow;
    ListBox1: TListBox;
    Button1: TButton;
    Button2: TButton;
    Filter1: TFilter;
    SampleGrabber1: TSampleGrabber;
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);

    function capturescreenrect(arect: trect): tbitmap;
    function captureclientimage(control: tcontrol): tbitmap;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  SysDev: TSysDevEnum;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  FilterGraph1.ClearGraph;
  FilterGraph1.Active := false;
  // 设filter为所选视频输入设备
  Filter1.BaseFilter.Moniker := SysDev.GetMoniker(ListBox1.ItemIndex);
  FilterGraph1.Active := true;
  // 打开所选的视频输入设备
  with FilterGraph1 as ICaptureGraphBuilder2 do
    // RenderStream(@PIN_CATEGORY_PREVIEW, nil, Filter1 as IBaseFilter, nil,
    // VideoWindow1 as IBaseFilter);
    RenderStream(@PIN_CATEGORY_PREVIEW, nil, Filter1 as IBaseFilter,
      SampleGrabber1 as IBaseFilter, VideoWindow1 as IBaseFilter);
  // 显示出来
  FilterGraph1.Play;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  SampleGrabber1.GetBitmap(Image1.Picture.Bitmap);
  Image1.Refresh;
  Image1.Picture.SaveToFile('d:\temp\test.bmp');
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  SysDev.Free;
  FilterGraph1.ClearGraph;
  FilterGraph1.Active := false;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  i: integer;
begin
  // 读取系统中的视频输入设备
  SysDev := TSysDevEnum.Create(CLSID_VideoInputDeviceCategory);
  if SysDev.CountFilters > 0 then
    for i := 0 to SysDev.CountFilters - 1 do
    begin
      ListBox1.Items.Add(SysDev.Filters[i].FriendlyName)
    end;
end;

end.

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧