WEB开发网
开发学院软件开发Delphi 用mediaplay实现抓图 阅读

用mediaplay实现抓图

 2006-02-04 13:37:29 来源:WEB开发网   
核心提示:小弟前段时间曾做过保证要公开该问题的code(vc,bcb,dephi),刚开始小弟用拷屏的方法可抓下来总是黑呼呼的一片,用mediaplay实现抓图,后来在几位大虾的提示下用vc+directshow实现那该功能,可这样一来,难度大一点的问题都回避,全是乱抄,就必须用directshow来实现播放与初衷不合.从此我就

小弟前段时间曾做过保证要公开该问题的code(vc,bcb,dephi),刚开始小弟用拷屏的方法可抓下来总是黑呼呼的一片,后来在几位大虾的提示下用vc+directshow实现那该功能。

可这样一来,就必须用directshow来实现播放与初衷不合.从此我就钻进那死胡同,总是想将

directshow与activemove组件,directshow与mediaplay组件结合起来,利用IBasicVideo Interface来达到目标。可读遍那与此相关的directsdk的头文件,都没有找那结合的办法(那位大虾实现那,请指点小弟,小弟先谢那!)。一直苦无进展,市面上有关的书都翻遍那。无用!(可见那些所谓的“高级编程技巧”都是狗屁,难度大一点的问题都回避,全是乱抄,tmd骗子),有一天小弟重读The IBasicVideo interface supports the video PRoperties of a generic video window. Generally, this is a video renderer that draws video into a window on the display. (msdn),忽然记起在读dephihelp是有一段相似

TPaintBox provides a canvas that applications can use for rendering an image.(dephihelp)遂想用paintbox可能可以,try->success,code如下:

unit Unit1;

interface

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, MPlayer, ExtCtrls, StdCtrls, Menus;

type

  TForm1 = class(TForm)

   MainMenu1: TMainMenu;

   filw1: TMenuItem;

   open1: TMenuItem;

   close1: TMenuItem;

   Button1: TButton;

   OpenDialog1: TOpenDialog;

   PaintBox1: TPaintBox;

   MediaPlayer1: TMediaPlayer;

   procedure FormCreate(Sender: TObject);

   procedure FormClose(Sender: TObject; var Action: TCloseAction);

   procedure PaintBox1Paint(Sender: TObject);

   procedure open1Click(Sender: TObject);

   procedure Button1Click(Sender: TObject);

  private

  imgbitmap:TBitmap;

   { Private declarations }

  public

   { Public declarations }

  end;

var

  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);

begin

  imgbitmap:=TBitmap.Create;

  imgbitmap.Height:=200;

  imgbitmap.Width:=200;

  imgbitmap.Canvas.Rectangle(0,0,200,200);

end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);

begin

imgbitmap.Free;

end;

procedure TForm1.PaintBox1Paint(Sender: TObject);

begin

PaintBox1.Canvas.CopyRect(Rect(0,0,200,200),imgbitmap.Canvas,Rect(0,0,200,200));

end;

procedure TForm1.open1Click(Sender: TObject);

begin

if OpenDialog1.Execute then

begin

MediaPlayer1.FileName:=OpenDialog1.FileName;

MediaPlayer1.Open;

MediaPlayer1.Display:=Form1;

MediaPlayer1.DisplayRect:=Rect(10,10,200,200);

end;

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

imgbitmap.Canvas.CopyRect(Rect(0,0,200,200),form1.Canvas,Rect(10,10,200,200));

PaintBox1.Invalidate;

imgbitmap.SaveToFile('d:\\1234567.bmp');

end;

end.

Tags:mediaplay 实现

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接