?? drawdib.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 LanMsg.AV
{
/// <summary>
/// DrawDib 的摘要說明。
/// </summary>
public class DrawDib
{
public Rectangle SrcRect,DstRect;
IntPtr hdd;
public Control Control;
public BITMAPINFOHEADER BITMAPINFOHEADER;
public IntPtr Handle
{
get{return this.hdd;}
}
public DrawDib()
{
this.SrcRect=this.DstRect=new Rectangle(0,0,160,120);
}
public void Open()
{
this.hdd=DrawDibOpen();
Debug.Assert(hdd!=IntPtr.Zero);
bool b=DrawDibBegin(hdd,IntPtr.Zero,this.DstRect.Width,this.DstRect.Height,ref this.BITMAPINFOHEADER,this.SrcRect.Width,this.SrcRect.Height,0);
}
public void Draw(byte[] data,int width,int height)
{
using(Graphics g=this.Control.CreateGraphics())
{
IntPtr hdc=g.GetHdc();
bool b=DrawDibDraw(
hdd,
hdc,
this.DstRect.X,
this.DstRect.Y,
width,
height,
ref this.BITMAPINFOHEADER,
data,
this.SrcRect.X,
this.SrcRect.Y,width,height,0);
g.ReleaseHdc(hdc);
}
}
public void Draw(byte[] data)
{
using(Graphics g=this.Control.CreateGraphics())
{
IntPtr hdc=g.GetHdc();
bool b=DrawDibDraw(
hdd,
hdc,
this.DstRect.X,
this.DstRect.Y,
this.DstRect.Width,
this.DstRect.Height,
ref this.BITMAPINFOHEADER,
data,
this.SrcRect.X,
this.SrcRect.Y,this.SrcRect.Width,this.SrcRect.Height,0);
g.ReleaseHdc(hdc);
}
}
public void Close()
{
if(hdd!=IntPtr.Zero)
{
DrawDibEnd(hdd);
DrawDibClose(hdd);
}
}
public bool IsOpened
{
get{return this.hdd!=IntPtr.Zero;}
}
#region
/*
** DrawDibOpen()
**
*/
[DllImport("MSVFW32.dll")]
public static extern IntPtr DrawDibOpen();
/*
** DrawDibClose()
**
*/
[DllImport("MSVFW32.dll")]
public static extern bool DrawDibClose(IntPtr hdd);
[DllImport("MSVFW32.dll")]
public static extern bool DrawDibBegin(
IntPtr hdd,
IntPtr hdc,
int dxDst,
int dyDst,
ref BITMAPINFOHEADER lpbi,
int dxSrc,
int dySrc,
int wFlags
);
[DllImport("MSVFW32.dll")]
public static extern bool DrawDibEnd(IntPtr hdd);
/*
** DrawDibDraw()
**
** actualy draw a DIB to the screen.
**
*/
[DllImport("MSVFW32.dll")]
public static extern bool DrawDibDraw(
IntPtr hdd,
IntPtr hdc,
int xDst,
int yDst,
int dxDst,
int dyDst,
ref BITMAPINFOHEADER lpbi,
byte[] lpBits,
int xSrc,
int ySrc,
int dxSrc,
int dySrc,
uint wFlags
);
#endregion
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -