如何把屏幕转换为Graphics对象啊
解决方案 »
- 从一个字符串中找出出现频率最高的字符
- winform datagridview 默认不选中第一行,试过好几种方法都没效果.
- 让ALT键处于长按下状态--委托
- 求Wrox Beginning Visual C Sharp 2005中文版
- 继续问调出“SDK命令提示”
- 如何引用表中的字段?
- C#中的ListView添加记录时会引发ItemChecked事件,怎么办?
- 如何开发一个继承datatable,可序列化的组件?
- 是不是HttpWebRequest自己的问题
- 大家请关注。CSDN论讨功能上的一个缺陷,望CSDN加上。
- 如下这句话有错吗?是不是要在linkname.Text前面加lable??
- 图像扫描
Graphics dcG = Graphics.FromHwnd(IntPtr.Zero);
Bitmap bmp = new Bitmap(Width,Height,dcG);
Graphics bmpG = Graphics.FromImage(bmp);
IntPtr hdcDest = bmpG.GetHdc();
BitBlt(hdcDest,0,0,bmp.Width,bmp.Height,dc,Left,Top,0x00CC0020);
bmpG.ReleaseHdc(hdcDest);
bmpG.Dispose();
bmp.Save(@"c:\zlc.bmp",System.Drawing.Imaging.ImageFormat.Bmp);
bmp.Dispose();
dcG.Dispose();
ReleaseDC(IntPtr.Zero,dc);
api声明
[DllImport("user32.dll", CharSet=CharSet.Auto)]
static public extern IntPtr GetDC(IntPtr hWnd); [DllImport("user32.dll", CharSet=CharSet.Auto)]
static public extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
[DllImport("gdi32.dll", CharSet=CharSet.Auto)]
static public extern bool BitBlt(IntPtr hdcDest, // handle to destination device context
int nXDest, // x-coordinate of destination rectangle's upper-left corner
int nYDest, // y-coordinate of destination rectangle's upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
IntPtr hdcSrc, // handle to source device context
int nXSrc, // x-coordinate of source rectangle's upper-left corner
int nYSrc, // y-coordinate of source rectangle's upper-left corner
uint dwRop); // raster operation code );
private static extern IntPtr CreateDC (
string lpszDriver , // 驱动名称
string lpszDevice , // 设备名称
string lpszOutput , // 无用,可以设定位"NULL"
IntPtr lpInitData // 任意的打印机数据
) ; //创建显示器的DC
IntPtr dc1 = CreateDC ( "DISPLAY" , null , null , ( IntPtr ) null ) ;
//由一个指定设备的句柄创建一个新的Graphics对象
Graphics g1 = Graphics.FromHdc ( dc1 ) ;
资深C#专业QQ群组联盟,首群号11440220 ,汇集1000多位C#程序爱好者,欢迎加入,共同交流学习!支持论坛 www.Tushu.info