📄 utiilities.cs
字号:
public int dwValue;
}
/*
* typedef struct {
DWORD cbStruct;
DWORD dwDestination;
DWORD dwSource;
DWORD dwLineID;
DWORD fdwLine;
DWORD dwUser;
DWORD dwComponentType;
DWORD cChannels;
DWORD cConnections;
DWORD cControls;
CHAR szShortName[MIXER_SHORT_NAME_CHARS];
CHAR szName[MIXER_LONG_NAME_CHARS];
struct {
DWORD dwType;
DWORD dwDeviceID;
WORD wMid;
WORD wPid;
MMVERSION vDriverVersion;
CHAR szPname[MAXPNAMELEN];
} Target;
} MIXERLINE;
*/
[StructLayout(LayoutKind.Sequential)]
public struct MIXERLINE
{
public int cbStruct;
public uint dwDestination;
public uint dwSource;
public uint dwLineID;
public int fdwLine;
public int dwUser;
public int dwComponentType;
public int cChannels;
public int cConnections;
public int cControls;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=16)]
public string szShortName;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=64)]
public string szName;
public Target tTarget;
}
[StructLayout(LayoutKind.Sequential)]
public struct Target
{
public int dwType;
public int dwDeviceID;
public short wMid;
public short wPid;
public int vDriverVersion;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]
public string szPname;
}
/*typedef struct {
DWORD cbStruct;
DWORD dwLineID;
union {
DWORD dwControlID;
DWORD dwControlType;
};
DWORD cControls;
DWORD cbmxctrl;
LPMIXERCONTROL pamxctrl;
} MIXERLINECONTROLS;
*/
[StructLayout(LayoutKind.Sequential)]
public struct MIXERLINECONTROLS
{
public int cbStruct;
public uint dwLineID;
//union
//{
// DWORD dwControlID;
// DWORD dwControlType;
//};
public int dwControlType;
public int cControls;
public int cbmxctrl;
public IntPtr pamxctrl;
}
#endregion
#region compress
/// <summary>
/// Values for dwFlags of ICOpen()
/// </summary>
public enum ICMODE
{
ICMODE_COMPRESS=1,
ICMODE_DECOMPRESS=2,
ICMODE_FASTDECOMPRESS=3,
ICMODE_QUERY=4,
ICMODE_FASTCOMPRESS=5,
ICMODE_DRAW=8
}
public class FOURCC
{
//关于更多四字码的信息,请参照 http://www.fourcc.org/codecs.php
//或者,查看你的注册表 HKLM\SoftWare\Microsoft\Windows NT\CurrentVersion\Drivers32
//在这里,我们采用Intel IYUV压缩编码,因为安装文件小而且一般windows自带
public static readonly int DIVX=mmioFOURCC('d','i','v','x'); //这个是需要安装的,windows不自带,效果非常好
public static readonly int XVID = mmioFOURCC('X', 'V', 'I', 'D'); //这个是需要安装的,windows不自带
public static readonly int MP42=mmioFOURCC('M','P','4','2'); //说是说WMP自带,但是我的win2003就没有
public static readonly int streamtypeVIDEO = mmioFOURCC('v', 'i', 'd', 's');
public static readonly int streamtypeAUDIO = mmioFOURCC('a', 'u', 'd', 's');
public static readonly int streamtypeMIDI = mmioFOURCC('m', 'i', 'd', 's');
public static readonly int streamtypeTEXT = mmioFOURCC('t', 'x', 't', 's');
public static readonly int ICTYPE_VIDEO = mmioFOURCC('v', 'i', 'd', 'c'); //保留有效
public static readonly int ICTYPE_AUDIO = mmioFOURCC('a', 'u', 'd', 'c');
public static readonly int ICM_FRAMERATE = mmioFOURCC('F','r','m','R');
public static readonly int ICM_KEYFRAMERATE = mmioFOURCC('K','e','y','R');
public static readonly int comptypeDIB = mmioFOURCC('D','I','B',' ');
public static readonly int FOURCC_wave = mmioFOURCC('w', 'a', 'v', 'e');
public static readonly int FOURCC_WVPL = mmioFOURCC('w','v','p','l');
public static readonly int formtypeAVI = mmioFOURCC('A', 'V', 'I', ' ');
public static readonly int listtypeAVIHEADER = mmioFOURCC('h', 'd', 'r', 'l');
public static readonly int ckidAVIMAINHDR = mmioFOURCC('a', 'v', 'i', 'h');
public static readonly int listtypeSTREAMHEADER = mmioFOURCC('s', 't', 'r', 'l');
public static readonly int ckidSTREAMHEADER = mmioFOURCC('s', 't', 'r', 'h');
public static readonly int ckidSTREAMFORMAT = mmioFOURCC('s', 't', 'r', 'f');
public static readonly int ckidSTREAMHANDLERDATA = mmioFOURCC('s', 't', 'r', 'd');
public static readonly int ckidSTREAMNAME = mmioFOURCC('s', 't', 'r', 'n');
public static readonly int MicrosoftH263 = mmioFOURCC('m', '2', '6', '3'); //M263一般默认安装,不稳定
public static readonly int IntelH263 = mmioFOURCC('i', '2', '6', '3'); //不稳定
public static readonly int IntelI420 = mmioFOURCC('I', '4', '2', '0'); //Intel I420
public static readonly int IntelIYUV = mmioFOURCC('I', 'Y', 'U', 'V'); //Intel IYUV codec,我的win2003默认安装,效果很好!
public static readonly int IntelIndeo32 = mmioFOURCC('i', 'v', '3', '2'); //intel indeo video r3.2,所有windows自带压缩率高,但是图象质量太差
public static readonly int IntelIndeo41 = mmioFOURCC('i', 'v', '4', '1'); //intel indeo video r4.1,所有windows自带压缩率高,但是图象质量太差
public static readonly int IntelIndeo50 = mmioFOURCC('i', 'v', '5', '0'); //同上
public static readonly int listtypeAVIMOVIE = mmioFOURCC('m', 'o', 'v', 'i');
public static readonly int listtypeAVIRECORD = mmioFOURCC('r', 'e', 'c', ' ');
public static readonly int On2VP31 = mmioFOURCC('v', 'p', '3', '1');
public static readonly int ckidAVINEWINDEX = mmioFOURCC('i', 'd', 'x', '1');
public static readonly int MJPG = mmioFOURCC('M', 'J', 'P', 'G'); //不稳定,一般用于播放
public static readonly int dmb1 = mmioFOURCC('d', 'm', 'b', '1');
public static readonly int MicrosoftRLE = mmioFOURCC('m', 'r', 'l', 'e');
public static readonly int MicrosoftVideo1 = mmioFOURCC('M', 'S', 'V', 'C');
public static readonly int WinbondJPEG = mmioFOURCC('W', 'J', 'P', 'G');
public static readonly int WMP9 = mmioFOURCC('W', 'M', 'V', '3'); //windows media player 9 可是也是要安装,效果不错
public static readonly int HuffYUV = mmioFOURCC('H','F','Y','U');
public static readonly int X_264 = mmioFOURCC('X', '2', '6', '4'); //x264
public static readonly int ffds = mmioFOURCC('f', 'f', 'd', 's'); //暴风影音解码器,要安装,效果非常好
public static readonly int YVU9 = mmioFOURCC('Y', 'V', 'U', '9');
public static Int32 mmioFOURCC(char ch0, char ch1, char ch2, char ch3)
{
return ((Int32)(byte)(ch0) | ((byte)(ch1) << 8) |
((byte)(ch2) << 16) | ((byte)(ch3) << 24));
}
}
/// <summary>
/// constants for the biCompression field
/// </summary>
public enum BI
{
BI_RGB ,
BI_RLE8,
BI_RLE4 ,
BI_BITFIELDS ,
BI_JPEG ,
BI_PNG ,
}
/// <summary>
/// Flags for index
/// </summary>
public enum AVIIF
{
AVIIF_LIST = 0x00000001, // chunk is a 'LIST'
AVIIF_KEYFRAME = 0x00000010, // this frame is a key frame.
AVIIF_FIRSTPART = 0x00000020, // this frame is the start of a partial frame.
AVIIF_LASTPART = 0x00000040, // this frame is the end of a partial frame.
AVIIF_MIDPART =0x00000040|0x00000020, //(AVIIF_LASTPART|AVIIF_FIRSTPART)
AVIIF_NOTIME = 0x00000100, // this frame doesn't take any time
AVIIF_COMPUSE = 0x0FFF0000 // these bits are for compressor use
}
[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)]
public class ICINFO
{
public int dwSize;
public int fccType;
public int fccHandler;
public int dwFlags;
public int dwVersion;
public int dwVersionICM;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=16)]
public string szName;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=128)]
public string szDescription;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=128)]
public string szDriver;
}
[StructLayout(LayoutKind.Sequential)]
public class COMPVARS
{
public int cbSize;
public int dwFlags;
public int hic;
public int fccType;
public int fccHandler;
public IntPtr lpbiIn;
public IntPtr lpbiOut;
public int lpBitsOut;
public int lpBitsPrev;
public int lFrame;
public int lKey;
public int lDataRate;
public int lQ;
public int lKeyCount;
public int lpState;
public int cbState;
}
[System.Flags]
public enum ICDRAWFlag
{
ICDRAW_QUERY = 0x00000001, // test for support
ICDRAW_FULLSCREEN = 0x00000002, // draw to full screen
ICDRAW_HDC = 0x00000004, // draw to a HDC/HWND
ICDRAW_ANIMATE = 0x00000008, // expect palette animation
ICDRAW_CONTINUE = 0x00000010, // draw is a continuation of previous draw
ICDRAW_MEMORYDC = 0x00000020, // DC is offscreen, by the way
ICDRAW_UPDATING = 0x00000040, // We're updating, as opposed to playing
ICDRAW_RENDER = 0x00000080, // used to render data not draw it
ICDRAW_BUFFER = 0x00000100 // please buffer this data offscreen, we will need to update it
}
[System.Runtime.InteropServices.StructLayout(LayoutKind.Sequential)]
internal struct ICDRAWBEGIN
{
public ICDRAWFlag dwFlags; // flags
public IntPtr hpal; // palette to draw with
public IntPtr hwnd; // window to draw to
public IntPtr hdc; // HDC to draw to
public int xDst; // destination rectangle
public int yDst;
public int dxDst;
public int dyDst;
public IntPtr lpbi; // format of frame to draw
public int xSrc; // source rectangle
public int ySrc;
public int dxSrc;
public int dySrc;
public int dwRate; // frames/second = (dwRate/dwScale)
public int dwScale;
}
#endregion
public class SendMessageClass
{
[DllImport("USER32.DLL")]
public static extern int SendMessage(
IntPtr hwnd,
int wMsg,
int wParam,
int lParam
);
[DllImport("USER32.DLL")]
public static extern int SendMessage(
IntPtr hwnd,
int wMsg,
int wParam,
IntPtr lParam
);
[DllImport("USER32.DLL")]
public static extern int SendMessage(
IntPtr hwnd,
int wMsg,
int wParam,
StringBuilder lParam
);
[DllImport("USER32.DLL")]
public static extern int SendMessage(
IntPtr hwnd,
int wMsg,
int wParam,
string lParam
);
[DllImport("USER32.DLL")]
public static extern int SendMessage(
IntPtr hwnd,
int wMsg,
bool wParam,
string lParam
);
[DllImport("USER32.DLL")]
public static extern int SendMessage(
IntPtr hwnd,
int wMsg,
bool wParam,
int lParam
);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -