C# 使用DirectX直接操作显卡 对于这方面我基本上不太了解。首先需要人回答如何使用DirectX直接操作显存。能够对显存中的内容进行编辑等操作然后请问在C#下能够直接使用DirectX进行如上的操作么?DirectX的版本要在9.0以上,DirectDraw就不用考虑了希望能有详细的解说,或者详细的教材,最好能有个例子,因为我对这方面的知识了解不多。分数不够可以再加。希望大家能帮帮忙! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 C++使用DirectX更好些,其中一些结构等的定义在C#中转来转去会很麻烦的,还不一定一次能转对的。 在添加Microsoft.DirectX.AudioVideoPlayback引用private void InitializeComponent ( ) { this.panel1 = new System.Windows.Forms.Panel ( ) ; this.button1 = new System.Windows.Forms.Button ( ) ; this.button2 = new System.Windows.Forms.Button ( ) ; this.button3 = new System.Windows.Forms.Button ( ) ; this.button4 = new System.Windows.Forms.Button ( ) ; this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog ( ) ; this.SuspendLayout ( ) ; this.panel1.Dock = System.Windows.Forms.DockStyle.Top ; this.panel1.Location = new System.Drawing.Point ( 0, 0 ) ; this.panel1.Name = "panel1" ; this.panel1.Size = new System.Drawing.Size ( 540, 346 ) ; this.panel1.TabIndex = 0 ; this.button1.Location = new System.Drawing.Point ( 62, 380 ) ; this.button1.Name = "button1" ; this.button1.Size = new System.Drawing.Size ( 80, 38 ) ; this.button1.TabIndex = 1 ; this.button1.Text = "打开" ; this.button1.Click += new System.EventHandler ( this.button1_Click ) ; this.button2.Location = new System.Drawing.Point ( 165, 380 ) ; this.button2.Name = "button2" ; this.button2.Size = new System.Drawing.Size ( 81, 38 ) ; this.button2.TabIndex = 1 ; this.button2.Text = "播放" ; this.button2.Click += new System.EventHandler ( this.button2_Click ) ; this.button3.Location = new System.Drawing.Point ( 268, 380 ) ; this.button3.Name = "button3" ; this.button3.Size = new System.Drawing.Size ( 80, 38 ) ; this.button3.TabIndex = 1 ; this.button3.Text = "暂停" ; this.button3.Click += new System.EventHandler ( this.button3_Click ) ; this.button4.Location = new System.Drawing.Point ( 371, 380 ) ; this.button4.Name = "button4" ; this.button4.Size = new System.Drawing.Size ( 81, 38 ) ; this.button4.TabIndex = 1 ; this.button4.Text = "停止" ; this.button4.Click += new System.EventHandler ( this.button4_Click ) ; this.openFileDialog1.DefaultExt = "avi" ; this.openFileDialog1.Filter = "视频文件|*.avi||" ; this.openFileDialog1.Title = "请选择播放的AVI文件" ; this.AutoScaleBaseSize = new System.Drawing.Size ( 6, 14 ) ; this.ClientSize = new System.Drawing.Size ( 540, 461 ) ; this.Controls.Add ( this.button1 ) ; this.Controls.Add ( this.panel1 ) ; this.Controls.Add ( this.button2 ) ; this.Controls.Add ( this.button3 ) ; this.Controls.Add ( this.button4 ) ; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog ; this.MaximizeBox = false ; this.Name = "Form1" ; this.Text = "Visual C#中使用DriectX实现媒体播放" ; this.Load += new System.EventHandler ( this.Form1_Load ) ; this.ResumeLayout ( false ) ;}后台代码private void button1_Click ( object sender, System.EventArgs e ) { openFileDialog1.InitialDirectory = Application.StartupPath ; if ( openFileDialog1.ShowDialog ( ) == DialogResult.OK ) { // 记录panel组件的大小 int height = panel1.Height ; int width = panel1.Width ; // 如果存在打开的Video文件,释放它 if ( MyVideo != null ) { MyVideo.Dispose ( ) ; } // 打开一个新的Video文件 MyVideo = new Video ( openFileDialog1.FileName ) ; // 把Video文件分配给创建的Panel组件 MyVideo.Owner = panel1 ; // 以记录的panel组件的大小来重新定义 panel1.Width = width ; panel1.Height = height ; // 播放AVI文件的第一帧,主要是为了在panel中显示 MyVideo.Play ( ) ; MyVideo.Pause ( ) ; } //确定窗体中的各按钮状态 if ( MyVideo == null ) { button2.Enabled = false ; button3.Enabled = false ; button4.Enabled = false ; } else { button2.Enabled = true ; button3.Enabled = true ; button4.Enabled = true ; }}private void button2_Click ( object sender, System.EventArgs e ) { if ( MyVideo != null ) { MyVideo.Play ( ) ; }}private void button3_Click ( object sender, System.EventArgs e ) { if ( MyVideo != null ) { MyVideo.Pause ( ) ; }}private void button4_Click ( object sender, System.EventArgs e ) { if ( MyVideo != null ) { MyVideo.Stop ( ) ; }} 3楼的大哥我要的是directx对显存的操作,不是Video类来播放视屏 安装managed directx 或者XNA的SDK,初始化以后建立一个纹理或者顶点缓冲区或者顶点索引缓冲区,然后lock一下得到一个指针,往指针里面写入数据,unlock的时候数据就会被传送到显存。 managed directx 就可以的,简单得很。 你去网上搜啊,一大堆,肯定要先看些教程的深入Managed DirectX9http://hi.baidu.com/gookings/blog/item/863e64f00252c4c47931aaba.html 你可以试试XNA.. 它就是DirectX的.NET版本.不过国内资料较少. 所以要求你的英语最好过关. 直接操作显存是什么概念?WPF就是基于DX的,c#语言的。 关于Solr分页问题 各位逻辑思维强的牛人大大们请进 数据库读入读出image类型的问题 C# 神啊,我变傻啦? c# 画图问题,高手请教了 谢谢 弱弱滴问下,C#中有这种东东不? 请问CS的分页问题。 请问这段VB代码用C#怎么写? !急! 关于操作Access数据报System.Data.OleDb.OleDbException: INSERT INTO 语句的语法错误异常问题 各位大哥。在C#怎么样调用VB或VC中的控件 C#加法问题 (Help)DVR&DVS跟手机媒体网关服务器连接及视频格式问题。。。
{
this.panel1 = new System.Windows.Forms.Panel ( ) ;
this.button1 = new System.Windows.Forms.Button ( ) ;
this.button2 = new System.Windows.Forms.Button ( ) ;
this.button3 = new System.Windows.Forms.Button ( ) ;
this.button4 = new System.Windows.Forms.Button ( ) ;
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog ( ) ;
this.SuspendLayout ( ) ;
this.panel1.Dock = System.Windows.Forms.DockStyle.Top ;
this.panel1.Location = new System.Drawing.Point ( 0, 0 ) ;
this.panel1.Name = "panel1" ;
this.panel1.Size = new System.Drawing.Size ( 540, 346 ) ;
this.panel1.TabIndex = 0 ;
this.button1.Location = new System.Drawing.Point ( 62, 380 ) ;
this.button1.Name = "button1" ;
this.button1.Size = new System.Drawing.Size ( 80, 38 ) ;
this.button1.TabIndex = 1 ;
this.button1.Text = "打开" ;
this.button1.Click += new System.EventHandler ( this.button1_Click ) ;
this.button2.Location = new System.Drawing.Point ( 165, 380 ) ;
this.button2.Name = "button2" ;
this.button2.Size = new System.Drawing.Size ( 81, 38 ) ;
this.button2.TabIndex = 1 ;
this.button2.Text = "播放" ;
this.button2.Click += new System.EventHandler ( this.button2_Click ) ;
this.button3.Location = new System.Drawing.Point ( 268, 380 ) ;
this.button3.Name = "button3" ;
this.button3.Size = new System.Drawing.Size ( 80, 38 ) ;
this.button3.TabIndex = 1 ;
this.button3.Text = "暂停" ;
this.button3.Click += new System.EventHandler ( this.button3_Click ) ;
this.button4.Location = new System.Drawing.Point ( 371, 380 ) ;
this.button4.Name = "button4" ;
this.button4.Size = new System.Drawing.Size ( 81, 38 ) ;
this.button4.TabIndex = 1 ;
this.button4.Text = "停止" ;
this.button4.Click += new System.EventHandler ( this.button4_Click ) ;
this.openFileDialog1.DefaultExt = "avi" ;
this.openFileDialog1.Filter = "视频文件|*.avi||" ;
this.openFileDialog1.Title = "请选择播放的AVI文件" ;
this.AutoScaleBaseSize = new System.Drawing.Size ( 6, 14 ) ;
this.ClientSize = new System.Drawing.Size ( 540, 461 ) ;
this.Controls.Add ( this.button1 ) ;
this.Controls.Add ( this.panel1 ) ;
this.Controls.Add ( this.button2 ) ;
this.Controls.Add ( this.button3 ) ;
this.Controls.Add ( this.button4 ) ;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog ;
this.MaximizeBox = false ;
this.Name = "Form1" ;
this.Text = "Visual C#中使用DriectX实现媒体播放" ;
this.Load += new System.EventHandler ( this.Form1_Load ) ;
this.ResumeLayout ( false ) ;
}后台代码private void button1_Click ( object sender, System.EventArgs e )
{
openFileDialog1.InitialDirectory = Application.StartupPath ;
if ( openFileDialog1.ShowDialog ( ) == DialogResult.OK )
{
// 记录panel组件的大小
int height = panel1.Height ;
int width = panel1.Width ;
// 如果存在打开的Video文件,释放它
if ( MyVideo != null )
{
MyVideo.Dispose ( ) ;
}
// 打开一个新的Video文件
MyVideo = new Video ( openFileDialog1.FileName ) ;
// 把Video文件分配给创建的Panel组件
MyVideo.Owner = panel1 ;
// 以记录的panel组件的大小来重新定义
panel1.Width = width ;
panel1.Height = height ;
// 播放AVI文件的第一帧,主要是为了在panel中显示
MyVideo.Play ( ) ;
MyVideo.Pause ( ) ;
}
//确定窗体中的各按钮状态
if ( MyVideo == null )
{
button2.Enabled = false ;
button3.Enabled = false ;
button4.Enabled = false ;
}
else
{
button2.Enabled = true ;
button3.Enabled = true ;
button4.Enabled = true ;
}
}private void button2_Click ( object sender, System.EventArgs e )
{
if ( MyVideo != null )
{
MyVideo.Play ( ) ;
}
}private void button3_Click ( object sender, System.EventArgs e )
{
if ( MyVideo != null )
{
MyVideo.Pause ( ) ;
}
}private void button4_Click ( object sender, System.EventArgs e )
{
if ( MyVideo != null )
{
MyVideo.Stop ( ) ;
}
}
深入Managed DirectX9
http://hi.baidu.com/gookings/blog/item/863e64f00252c4c47931aaba.html
不过国内资料较少. 所以要求你的英语最好过关.