private void ImageCreat() { int w = 0, h = 0; MVSTATUS r = MVGigE.MVGetWidth(m_hCam, out w); if (r != MVSTATUS.MVST_SUCCESS) { Util.Notify("取得图像宽度失败"); return; } r = MVGigE.MVGetHeight(m_hCam, out h); if (r != MVSTATUS.MVST_SUCCESS) { Util.Notify("取得图像高度失败"); return; } r = MVGigE.MVGetPixelFormat(m_hCam, out m_PixelFormat); if (r != MVSTATUS.MVST_SUCCESS) { Util.Notify("取得图像颜色模式失败"); return; } if (m_nWidth != w || m_nHeight != h) { m_nWidth = w; m_nHeight = h; if (m_hImage != IntPtr.Zero) { MVAPI.MVImage.MVImageRelease(m_hImage); m_hImage = IntPtr.Zero; } if (m_PixelFormat == MVAPI.MV_PixelFormatEnums.PixelFormat_Mono8) { m_hImage = MVAPI.MVImage.MVImageCreate(w, h, 8); } else { m_hImage = MVAPI.MVImage.MVImageCreate(w, h, 24); } } }