现在的位置: 首页 > 综合 > 正文

C#摄像头实现拍照功能的简单代码示例

2013年06月14日 ⁄ 综合 ⁄ 共 1558字 ⁄ 字号 评论关闭

C#摄像头实现拍照功能的简单代码示例

  1. using System;  
  2. using System.Runtime.InteropServices;  
  3. using System.Drawing;  
  4. using System.Drawing.Imaging;  
  5. namespace Video  
  6. {  
  7. ///   
  8. /// 一个C#摄像头控制类  
  9. ///   
  10. public class VideoWork  
  11. {  
  12. private const int WM_USER = 0x400;  
  13. private const int WS_CHILD = 0x40000000;  
  14. private const int WS_VISIBLE = 0x10000000;  
  15. private const int WM_CAP_START = WM_USER;  
  16. private const int WM_CAP_STOP = WM_CAP_START + 68;  
  17. private const int WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10;  
  18. private const int WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11;  
  19. private const int WM_CAP_SAVEDIB = WM_CAP_START + 25;  
  20. private const int WM_CAP_GRAB_FRAME = WM_CAP_START + 60;  
  21. private const int WM_CAP_SEQUENCE = WM_CAP_START + 62;  
  22. private const int WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20;  
  23. private const int WM_CAP_SEQUENCE_NOFILE =WM_CAP_START+ 63;  
  24. private const int WM_CAP_SET_OVERLAY =WM_CAP_START+ 51;   
  25. private const int WM_CAP_SET_PREVIEW =WM_CAP_START+ 50;   
  26. private const int WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START +6;  
  27. private const int WM_CAP_SET_CALLBACK_ERROR=WM_CAP_START +2;  
  28. private const int WM_CAP_SET_CALLBACK_STATUSA= WM_CAP_START +3;  
  29. private const int WM_CAP_SET_CALLBACK_FRAME= WM_CAP_START +5;  
  30. private const int WM_CAP_SET_SCALE=WM_CAP_START+ 53;  
  31. private const int WM_CAP_SET_PREVIEWRATE=WM_CAP_START+ 52;   
  32. private IntPtr hWndC;  
  33. private bool bWorkStart = false;  
  34. private IntPtr mControlPtr;  
  35. private int mWidth;  
  36. private int mHeight;  
  37. private int mLeft;  
  38. private int mTop;  
  39.  
  40. ///   
  41. /// 初始化显示图像  
  42. ///   
  43. /// 控件的句柄  
  44. /// 开始显示的左边距  
  45. /// 开始显示的上边距  
  46. /// 要显示的宽度  
  47. /// 要显示的长度  <

抱歉!评论已关闭.