MVCAPI.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace ivf_tl_Entity.CameraEntitys
  8. {
  9. public class MVCAPI
  10. {
  11. public delegate void LPMV_CALLBACK2(IntPtr lpParam, IntPtr lpUser);
  12. public const short ResSuccess = 0x0000;
  13. public const short ResNullHandleErr = 0x0001;
  14. public const short ResNullPointerErr = 0x0002;
  15. public const short ResFileOpenErr = 0x0003;
  16. public const short ResNoDeviceErr = 0x0004;
  17. public const short ResInvalidParameterErr = 0x0005;
  18. public const short ResOutOfMemoryErr = 0x0006;
  19. public const short ResNoPreviewRunningErr = 0x0007;
  20. public const short ResOSVersionErr = 0x0008;
  21. public const short ResUsbNotAvailableErr = 0x0009;
  22. public const short ResNotSupportedErr = 0x000a;
  23. public const short ResNoSerialString = 0x000b;
  24. public const short ResVerificationErr = 0x000c;
  25. public const short ResUnknowErr = 0x00ff;
  26. public const int WS_CHILD = 0x40000000;
  27. public const int WS_VISIBLE = 0x10000000;
  28. //public static uint WS_CHILD = 1073741824u;
  29. //public static uint WS_VISIBLE = 268435456u;
  30. [DllImport(@"Resources\ccd\mvcapi.dll")]
  31. public static extern Int32 MV_Usb2Init(String pFilterName, out int index, ref CapInfoStruct pCapInfo, out IntPtr hImager);
  32. [DllImport(@"Resources\ccd\mvcapi.dll")]
  33. public static extern Int32 MV_Usb2GetSerial(IntPtr hImager, StringBuilder number);
  34. /// <summary>
  35. /// 卸载相机,成功返回0
  36. /// </summary>
  37. /// <param name="hImager"></param>
  38. /// <returns></returns>
  39. [DllImport(@"Resources\ccd\mvcapi.dll")]
  40. public static extern Int32 MV_Usb2Uninit(ref IntPtr hImager);
  41. [DllImport(@"Resources\ccd\mvcapi.dll")]
  42. public static extern Int32 MV_Usb2Start(IntPtr hImager, String tilte, uint style, int x, int y, int width, int height, IntPtr parent, uint nId, int ViewDataThreadPriority, int ViewDrawThreadPriority);
  43. [DllImport(@"Resources\ccd\mvcapi.dll")]
  44. public static extern Int32 MV_Usb2StartCapture(IntPtr hImager, bool bCapture);
  45. [DllImport(@"Resources\ccd\mvcapi.dll")]
  46. public static extern Int32 MV_Usb2Stop(IntPtr hImager);
  47. [DllImport(@"Resources\ccd\mvcapi.dll")]
  48. public static extern Int32 MV_Usb2PausePreview(IntPtr hImager, bool bPause);
  49. [DllImport(@"Resources\ccd\mvcapi.dll")]
  50. public static extern Int32 MV_Usb2GetFrameRate(IntPtr hImager, out float nRate);
  51. /**************************************************/
  52. [DllImport(@"Resources\ccd\mvcapi.dll")]
  53. public static extern Int32 MV_Usb2SetOpMode(IntPtr hImager, byte nMode, bool bStrobe);
  54. [DllImport(@"Resources\ccd\mvcapi.dll")]
  55. public static extern Int32 MV_Usb2SetPartOfCapInfo(IntPtr hImager, ref CapInfoStruct pCapInfo);
  56. [DllImport(@"Resources\ccd\mvcapi.dll")]
  57. public static extern Int32 MV_Usb2GetRgbData(IntPtr hImager, ref CapInfoStruct pCapInfo, IntPtr pDest);
  58. [DllImport(@"Resources\ccd\mvcapi.dll")]
  59. public static extern Int32 MV_Usb2GetRawData(IntPtr hImager, ref CapInfoStruct pCapInfo);
  60. [DllImport(@"Resources\ccd\mvcapi.dll")]
  61. public static extern Int32 MV_Usb2ConvertRawToRgb(IntPtr hImager, IntPtr pSrc, int width, int height, IntPtr pDest);
  62. [DllImport(@"Resources\ccd\mvcapi.dll")]
  63. public static extern Int32 MV_Usb2SaveFrameAsBmp(IntPtr hImager, ref CapInfoStruct pCapInfo, IntPtr pDest, string strname);
  64. [DllImport(@"Resources\ccd\mvcapi.dll")]
  65. public static extern Int32 MV_Usb2SetMaskCallBack(IntPtr hImager, LPMV_CALLBACK2 MaskCallBackFunction, IntPtr lpUser);
  66. [DllImport(@"Resources\ccd\mvcapi.dll")]
  67. public static extern Int32 MV_Usb2SetFrameCallBack(IntPtr hImager, LPMV_CALLBACK2 CALLBACKFUNCT, IntPtr lpUser);
  68. [DllImport(@"Resources\ccd\mvcapi.dll")]
  69. public static extern Int32 MV_Usb2SetMask(IntPtr hImager, bool bMask);
  70. [DllImport(@"Resources\ccd\MVCAPI.dll")]
  71. public static extern int MV_Usb2SavePausedFrameAsBmp(IntPtr hImager, string fileName);
  72. [DllImport(@"Resources\ccd\MVCAPI.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
  73. public static extern int MV_Usb2GetPausedRgbData(IntPtr intptr_device, IntPtr rgbdata);
  74. [DllImport(@"Resources\ccd\mvavi.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
  75. public static extern void MV_AVIFileInit(uint filetype, short framerate);
  76. [DllImport(@"Resources\ccd\mvavi.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
  77. public static extern void MV_AVIFileFini();
  78. /// <summary>
  79. /// 1是成功 0失败
  80. /// </summary>
  81. /// <param name="bitmapData"></param>
  82. /// <param name="width"></param>
  83. /// <param name="height"></param>
  84. /// <param name="path"></param>
  85. [DllImport(@"Resources\newccd\Project2.dll", EntryPoint = "#7", CallingConvention = CallingConvention.Cdecl)]
  86. public extern static int SavePic(byte[] bitmapData, int width, int height, string path);
  87. }
  88. }