📄 icdraw.cs
字号:
using System;
using System.Text;
using System.Drawing;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace gowk.multimedia
{
/// <summary>
/// ICDraw 的摘要说明。
/// </summary>
public class ICDrawer:ICM
{
private Control ctl;
public Control Control
{
get{return this.ctl;}
set{this.ctl=value;}
}
public Rectangle SrcRect,DstRect;
public ICDrawer(int fourcc):base(ICMODE.ICMODE_DRAW,fourcc)
{
}
public override void Open()//(IntPtr p)
{
base.Open();
BITMAPINFOHEADER h=this.InFormat.bmiHeader;
System.Drawing.Graphics g=this.Control.CreateGraphics();
IntPtr hdc=g.GetHdc();
// base.Open ();
int ret=ICDrawBegin(
this.HIC,
ICDRAWFlag.ICDRAW_HDC|ICDRAWFlag.ICDRAW_CONTINUE,
IntPtr.Zero,
this.Control.Handle,
hdc,
this.DstRect.X,this.DstRect.Y,this.DstRect.Width,this.DstRect.Height,
ref h,
this.SrcRect.X,this.SrcRect.Y,this.SrcRect.Width,this.SrcRect.Height,
this.Compvars.lDataRate,
(int)(this.Compvars.lDataRate/this.Compvars.lKey)
);
// g.ReleaseHdc(hdc);
// g.Dispose();
}
public override byte[] Process(byte[] data)
{
BITMAPINFOHEADER h=this.InFormat.bmiHeader;
// return base.Process (data);
try
{
int ret=ICDraw(this.HIC,0,ref h,data,data.Length,0);
}
catch(System.Exception ex)
{
MessageBox.Show(ex.Message);
}
// ICDraw(pDlg->m_CV.hic,0,&pDlg->m_InInfo.bmiHeader,VideoData.Buf,VideoData.nUsedSize,VideoData.nSampleNum);
return null;
}
protected override void Close()
{
if(this.HIC!=0)
ICM.ICSendMessage(this.HIC,ICM_DRAW_END,0,0);
base.Close ();
}
/* [DllImport("MSVFW32.dll")]
static extern int ICDrawBegin(
int hic,
ICDRAWFlag dwFlags, // flags
IntPtr hpal, // palette to draw with
IntPtr hwnd, // window to draw to
IntPtr hdc, // HDC to draw to
int xDst, // destination rectangle
int yDst,
int dxDst,
int dyDst,
ref BITMAPINFOHEADER lpbi, // format of frame to draw
int xSrc, // source rectangle
int ySrc,
int dxSrc,
int dySrc,
int dwRate, // frames/second = (dwRate/dwScale)
int dwScale
);*/
[DllImport("MSVFW32.dll")]
static extern int ICDraw(
int hic,
int dwFlags, // flags
ref BITMAPINFOHEADER lpFormat, // format of frame to decompress
byte[] lpData, // frame data to decompress
int cbData, // size of data
int lTime // time to draw this frame
);
static readonly uint ICDRAW_HURRYUP =0x80000000; // don't draw just buffer (hurry up!)
static readonly uint ICDRAW_UPDATE =0x40000000; // don't draw just update screen
static readonly int ICM_DRAW_END =(ICM_USER+21);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -