C# 如何获得屏幕上特定位置像素点的颜色属性? 调用哪些类?最好有源代码~~谢谢!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public class Win32APICall { [DllImport( "gdi32.dll ",EntryPoint= "DeleteDC ")] public static extern IntPtr DeleteDC(IntPtr hdc); [DllImport( "gdi32.dll ",EntryPoint= "DeleteObject ")] public static extern IntPtr DeleteObject(IntPtr hObject); [DllImport( "gdi32.dll ",EntryPoint= "BitBlt ")] public static extern bool BitBlt(IntPtr hdcDest,int nXDest, int nYDest,int nWidth,int nHeight,IntPtr hdcSrc, int nXSrc,int nYSrc,int dwRop); [DllImport ( "gdi32.dll ",EntryPoint= "CreateCompatibleBitmap ")] public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight); [DllImport ( "gdi32.dll ",EntryPoint= "CreateCompatibleDC ")] public static extern IntPtr CreateCompatibleDC(IntPtr hdc); [DllImport ( "gdi32.dll ",EntryPoint= "SelectObject ")] public static extern IntPtr SelectObject(IntPtr hdc,IntPtr hgdiobjBmp); [DllImport( "user32.dll ", EntryPoint= "GetDesktopWindow ")] public static extern IntPtr GetDesktopWindow(); [DllImport( "user32.dll ",EntryPoint= "GetDC ")] public static extern IntPtr GetDC(IntPtr hWnd); [DllImport( "user32.dll ",EntryPoint= "GetSystemMetrics ")] public static extern int GetSystemMetrics(int nIndex); [DllImport( "user32.dll ",EntryPoint= "ReleaseDC ")] public static extern IntPtr ReleaseDC(IntPtr hWnd,IntPtr hDC); public static Bitmap GetDesktop() { int screenX; int screenY; IntPtr hBmp; IntPtr hdcScreen = GetDC(GetDesktopWindow()); IntPtr hdcCompatible = CreateCompatibleDC(hdcScreen); screenX = GetSystemMetrics(0); screenY = GetSystemMetrics(1); hBmp = CreateCompatibleBitmap(hdcScreen, screenX, screenY); if (hBmp!=IntPtr.Zero) { IntPtr hOldBmp = (IntPtr) SelectObject(hdcCompatible, hBmp); BitBlt(hdcCompatible, 0, 0,screenX,screenY, hdcScreen, 0, 0,13369376); SelectObject(hdcCompatible, hOldBmp); DeleteDC(hdcCompatible); ReleaseDC(GetDesktopWindow(), hdcScreen); Bitmap bmp = System.Drawing.Image.FromHbitmap(hBmp); DeleteObject(hBmp); GC.Collect(); return bmp; } return null; } } http://topic.csdn.net/u/20090324/08/ab0e7ec6-f5de-4612-969f-ce348017bd96.html ////先创建图片//Bitmap bitmap = new Bitmap(// Screen.PrimaryScreen.Bounds.Width,// Screen.PrimaryScreen.Bounds.Height);////通过图片创建 Graphics//using (Graphics g = Graphics.FromImage(bitmap))//{// //截屏// g.CopyFromScreen(0, 0, 0, 0,// bitmap.Size, CopyPixelOperation.SourceCopy);// g.Save();//}通过图片取像素 Js 创建的控件的编号 如何动态获取 C# 写的购票小程序,过年要回家的童鞋的福音啊!!! RegularExpressionValidator的ValidationExpression属性 并非所有代码路径都返回值——关于把数组作为返回值传递的问题 VS2005 C#调试请教 webbrowser 如何不下载图片? [求助]几个郁闷的问题? 在线等! 急 Webservice问题 如何看到.ascx控件的效果 初学socket的疑惑 关于ImageList 的问题 如何向已经建立连接Socket的TCP客户端发送数据?
{
[DllImport( "gdi32.dll ",EntryPoint= "DeleteDC ")]
public static extern IntPtr DeleteDC(IntPtr hdc); [DllImport( "gdi32.dll ",EntryPoint= "DeleteObject ")]
public static extern IntPtr DeleteObject(IntPtr hObject); [DllImport( "gdi32.dll ",EntryPoint= "BitBlt ")]
public static extern bool BitBlt(IntPtr hdcDest,int nXDest,
int nYDest,int nWidth,int nHeight,IntPtr hdcSrc,
int nXSrc,int nYSrc,int dwRop); [DllImport ( "gdi32.dll ",EntryPoint= "CreateCompatibleBitmap ")]
public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc,
int nWidth, int nHeight); [DllImport ( "gdi32.dll ",EntryPoint= "CreateCompatibleDC ")]
public static extern IntPtr CreateCompatibleDC(IntPtr hdc); [DllImport ( "gdi32.dll ",EntryPoint= "SelectObject ")]
public static extern IntPtr SelectObject(IntPtr hdc,IntPtr hgdiobjBmp); [DllImport( "user32.dll ", EntryPoint= "GetDesktopWindow ")]
public static extern IntPtr GetDesktopWindow(); [DllImport( "user32.dll ",EntryPoint= "GetDC ")]
public static extern IntPtr GetDC(IntPtr hWnd); [DllImport( "user32.dll ",EntryPoint= "GetSystemMetrics ")]
public static extern int GetSystemMetrics(int nIndex); [DllImport( "user32.dll ",EntryPoint= "ReleaseDC ")]
public static extern IntPtr ReleaseDC(IntPtr hWnd,IntPtr hDC); public static Bitmap GetDesktop()
{
int screenX;
int screenY;
IntPtr hBmp;
IntPtr hdcScreen = GetDC(GetDesktopWindow());
IntPtr hdcCompatible = CreateCompatibleDC(hdcScreen); screenX = GetSystemMetrics(0);
screenY = GetSystemMetrics(1);
hBmp = CreateCompatibleBitmap(hdcScreen, screenX, screenY); if (hBmp!=IntPtr.Zero)
{
IntPtr hOldBmp = (IntPtr) SelectObject(hdcCompatible, hBmp);
BitBlt(hdcCompatible, 0, 0,screenX,screenY, hdcScreen, 0, 0,13369376); SelectObject(hdcCompatible, hOldBmp);
DeleteDC(hdcCompatible);
ReleaseDC(GetDesktopWindow(), hdcScreen); Bitmap bmp = System.Drawing.Image.FromHbitmap(hBmp); DeleteObject(hBmp);
GC.Collect(); return bmp;
} return null;
}
}
http://topic.csdn.net/u/20090324/08/ab0e7ec6-f5de-4612-969f-ce348017bd96.html
//Bitmap bitmap = new Bitmap(
// Screen.PrimaryScreen.Bounds.Width,
// Screen.PrimaryScreen.Bounds.Height);////通过图片创建 Graphics
//using (Graphics g = Graphics.FromImage(bitmap))
//{
// //截屏
// g.CopyFromScreen(0, 0, 0, 0,
// bitmap.Size, CopyPixelOperation.SourceCopy);
// g.Save();
//}通过图片取像素