public static extern int SetDisplayRegion(int nDisplayChannel, int nRegionCount, ref REGION_PARAM pParam, int nReserved);
public static REGION_PARAM[] GetStruDisplayRegion(DISPLAY_PARA struCardPlayInfo, int regionNumber) { REGION_PARAM[] struDisplayRegion = new REGION_PARAM[regionNumber]; int i; int row = (int)(Math.Sqrt(regionNumber)); var tempDisplayRegion = new REGION_PARAM[row, row]; int step = 64 / regionNumber; int nwidth = struCardPlayInfo.nWidth / row; int nheight = struCardPlayInfo.nHeight / row; for (int j = 0; j < row; j++) { for (int k = 0; k < row; k++) { tempDisplayRegion[j, k].top = (uint)(nheight * k); tempDisplayRegion[j, k].left = (uint)(nwidth * j); tempDisplayRegion[j, k].width = (uint)(nwidth); tempDisplayRegion[j, k].height = (uint)(nheight); } } for (i = 0; i < regionNumber; i++) { struDisplayRegion[i] = new REGION_PARAM(); struDisplayRegion[i] = tempDisplayRegion[i % row, i / row]; struDisplayRegion[i].color = (uint)(Color.FromArgb(128, i * step, 0, 0).ToArgb()); } return struDisplayRegion; }
public static extern int SetDecoderVideoExtOutput(int nDisplayChannel, int nPort, bool bOpen, ref REGION_PARAM pParam, int nReserved);
public void Init(IntPtr paraHandle) { TotalDSP = 0; int totalDSP = 0; //初始化板卡 IsValid = false; /* if (!HCNetSDK.NET_DVR_InitDDraw_Card(paraHandle, 0xffffff)) { errMessage = "设备初始化失败"; return; } int m_iCardChanCount = 0; if (!HCNetSDK.NET_DVR_InitDevice_Card(ref m_iCardChanCount)) { errMessage = "获取卡通道数失败"; return; } TotalDSP = m_iCardChanCount; if (TotalDSP == 0) { errMessage = "没有可用的通道!!您是否已经启动服务器端?"; return; }*/ int nDispNum = HikVisionSDK.GetDisplayChannelCount(); if (nDispNum >= 2) { REGION_PARAM[] struDisplayRegion = new REGION_PARAM[MAX_DISPLAY_REGION]; int i; for (i = 0; i < MAX_DISPLAY_REGION; i++) { struDisplayRegion[i] = new REGION_PARAM(); struDisplayRegion[i].color = (uint)(Color.FromArgb(i, i * 8, i * 16).ToArgb()); } for (i = 0; i < nDispNum / 2; i++) { HikVisionSDK.SetDisplayStandard(2 * i, VideoStandard_t.StandardPAL); struDisplayRegion[0].left = 0; struDisplayRegion[0].top = 0; struDisplayRegion[0].width = 352; struDisplayRegion[0].height = 240; struDisplayRegion[1].left = 352; struDisplayRegion[1].top = 0; struDisplayRegion[1].width = 352; struDisplayRegion[1].height = 240; struDisplayRegion[2].left = 0; struDisplayRegion[2].top = 240; struDisplayRegion[2].width = 352; struDisplayRegion[2].height = 240; struDisplayRegion[3].left = 352; struDisplayRegion[3].top = 240; struDisplayRegion[3].width = 352; struDisplayRegion[3].height = 240; if (HikVisionSDK.SetDisplayRegion(2 * i, 4, ref struDisplayRegion[0], 0) != HWERR_SUCCESS) { } HikVisionSDK.SetDecoderVideoExtOutput(4 * i, 0, true, 2 * i, 0, 0); HikVisionSDK.SetDecoderVideoExtOutput(4 * i + 1, 0, true, 2 * i, 1, 0); HikVisionSDK.SetDecoderVideoExtOutput(4 * i + 2, 0, true, 2 * i, 2, 0); HikVisionSDK.SetDecoderVideoExtOutput(4 * i + 3, 0, true, 2 * i, 3, 0); HikVisionSDK.SetDisplayStandard(2 * i + 1, VideoStandard_t.StandardPAL); struDisplayRegion[0].left = 0; struDisplayRegion[0].top = 0; struDisplayRegion[0].width = 704; struDisplayRegion[0].height = 480; if (HikVisionSDK.SetDisplayRegion(2 * i + 1, 1, ref struDisplayRegion[0], 0) != HWERR_SUCCESS) { // AddLog(m_iCurDeviceIndex, OPERATION_FAIL_T, "SetDisplayRegion failed!"); } HikVisionSDK.SetDecoderVideoExtOutput(4 * i, 1, true, 2 * i + 1, 0, 0); } } IsValid = true; }