正在阅读:.Net里一个用于驱动摄像头的类.Net里一个用于驱动摄像头的类

2005-01-05 15:34 出处:太平洋电脑网 作者:winxieddd 责任编辑:linjixiong


  mLeft = left;
  mTop = top;
  }

  [DllImport("avicap32.dll")]
  private static extern IntPtr capCreateCaptureWindowA(byte[] lpszWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, int nID);
  
  [DllImport("avicap32.dll")]
  private static extern int capGetVideoFormat(IntPtr hWnd, IntPtr psVideoFormat, int wSize );
  [DllImport("User32.dll")]
  private static extern bool SendMessage(IntPtr hWnd, int wMsg, int wParam, long lParam);

  /// <summary>
  /// 开始显示图像
  /// </summary>
  public void Start()
  {
  if (bStat)
  return;
  
  bStat = true;
  byte[] lpszName = new byte[100];
  
  hWndC = capCreateCaptureWindowA(lpszName,WS_CHILD|WS_VISIBLE ,mLeft,mTop,mWidth,mHeight,mControlPtr,0);

  if (hWndC.ToInt32() != 0)
  {
  SendMessage(hWndC, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
  SendMessage(hWndC, WM_CAP_SET_CALLBACK_ERROR, 0, 0);
  SendMessage(hWndC, WM_CAP_SET_CALLBACK_STATUSA, 0, 0);
  SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0);
  SendMessage(hWndC, WM_CAP_SET_SCALE, 1, 0);
  SendMessage(hWndC, WM_CAP_SET_PREVIEWRATE, 66, 0);
  SendMessage(hWndC, WM_CAP_SET_OVERLAY, 1, 0);
  SendMessage(hWndC, WM_CAP_SET_PREVIEW, 1, 0);
  }

  return;

  }

  /// <summary>
  /// 停止显示


热点推荐: 
教你如何成为一名Java初级程序员变态级JAVA程序员面试32问(附答案)
将Asp.Net页面输出到EXCEL里去读书笔记:程序员的个人性格
Java编程学习:自己DIY一个JSP日历Java 的破解和反破解之道
网页编程必看:XML文法分析设计模式的有趣解释-追MM

察看评论详细内容 我要发表评论
作者笔名 简短内容 发表时间
:

键盘也能翻页,试试“← →”键

关注我们

最新资讯离线随时看 聊天吐槽赢奖品