|
@@ -1121,6 +1121,12 @@ void CSettingPageUI::InitShow()
|
|
|
std::thread(&CSettingPageUI::HandleUpdateVideo, this).detach();
|
|
std::thread(&CSettingPageUI::HandleUpdateVideo, this).detach();
|
|
|
CAppEnv::GetInstance()->AddWorkerNum();
|
|
CAppEnv::GetInstance()->AddWorkerNum();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ //【R50】登记「后绘制」:摄像头帧与红色裁剪框都改由 DoPostPaint() 画进
|
|
|
|
|
+ //框架本帧真正提交的那张图(分层模式 = m_hDcOffscreen)。见 CAIxuexiPageUI.cpp
|
|
|
|
|
+ //里 UpdateVideoShow() 上方的说明。
|
|
|
|
|
+ m_pManager->RemovePostPaint(this);
|
|
|
|
|
+ m_pManager->AddPostPaint(this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//处理按钮点击类事件
|
|
//处理按钮点击类事件
|
|
@@ -3681,21 +3687,61 @@ void CSettingPageUI::HandleUpdateVideo()
|
|
|
CAppEnv::GetInstance()->DelWorkerNum(L"CSettingPageUI::HandleUpdateVideo");
|
|
CAppEnv::GetInstance()->DelWorkerNum(L"CSettingPageUI::HandleUpdateVideo");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//【R50】原实现直画 m_pManager->GetPaintDC()(窗口 DC),自 09-24 主窗口转为分层窗口后
|
|
|
|
|
+//全部不可见(连红色裁剪框一起)。现改为:本函数只标脏,绘制搬进 DoPostPaint()。
|
|
|
void CSettingPageUI::UpdateVideoShow()
|
|
void CSettingPageUI::UpdateVideoShow()
|
|
|
{
|
|
{
|
|
|
- HDC hDC = m_pManager->GetPaintDC();
|
|
|
|
|
|
|
+ if (m_pManager == NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ CControlUI* pImage = static_cast<CControlUI*>(this->FindSubControl(_T("image_video")));
|
|
|
|
|
+ if (pImage == NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //红色裁剪框被 IntersectClipRect 限在 image 里,所以脏区取 image 的矩形就够;
|
|
|
|
|
+ //外扩 2px 覆盖 2px 宽的画笔描边。
|
|
|
|
|
+ RECT rcDirty = pImage->GetPos();
|
|
|
|
|
+ ::InflateRect(&rcDirty, 2, 2);
|
|
|
|
|
+ m_pManager->Invalidate(rcDirty);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void CSettingPageUI::DoPostPaint(HDC hDC, const RECT& rcPaint)
|
|
|
|
|
+{
|
|
|
if (!hDC || !m_hBitmap)
|
|
if (!hDC || !m_hBitmap)
|
|
|
{
|
|
{
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!m_hMemDC)
|
|
|
|
|
|
|
+ //登记常驻,必须自己判断「本页是不是当前页、AI 识别子界面是不是开着」。
|
|
|
|
|
+ if (m_pMainWnd == NULL || m_pMainWnd->GetCurPageName() != CMainWnd::SETTING)
|
|
|
{
|
|
{
|
|
|
- m_hMemDC = CreateCompatibleDC(hDC);
|
|
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!m_is_show_video_capture)
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
CControlUI* pImage = static_cast<CControlUI*>(this->FindSubControl(_T("image_video")));
|
|
CControlUI* pImage = static_cast<CControlUI*>(this->FindSubControl(_T("image_video")));
|
|
|
- if (!pImage)
|
|
|
|
|
|
|
+ if (!pImage || !pImage->IsVisible())
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ RECT imageRect = pImage->GetPos();
|
|
|
|
|
+ RECT rcClip = { 0 };
|
|
|
|
|
+ if (!::IntersectRect(&rcClip, &rcPaint, &imageRect))
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int imageWidth = imageRect.right - imageRect.left;
|
|
|
|
|
+ int imageHeight = imageRect.bottom - imageRect.top;
|
|
|
|
|
+ if (imageWidth <= 0 || imageHeight <= 0)
|
|
|
{
|
|
{
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -3707,19 +3753,23 @@ void CSettingPageUI::UpdateVideoShow()
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- HBITMAP hOldBitmap = (HBITMAP)SelectObject(m_hMemDC, m_hBitmap);
|
|
|
|
|
|
|
+ if (!m_hMemDC)
|
|
|
|
|
+ {
|
|
|
|
|
+ m_hMemDC = CreateCompatibleDC(hDC);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!m_hMemDC)
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- RECT imageRect = pImage->GetPos();
|
|
|
|
|
- int imageWidth = imageRect.right - imageRect.left;
|
|
|
|
|
- int imageHeight = imageRect.bottom - imageRect.top;
|
|
|
|
|
- if (imageWidth <= 0 || imageHeight <= 0)
|
|
|
|
|
|
|
+ HBITMAP hOldBitmap = (HBITMAP)SelectObject(m_hMemDC, m_hBitmap);
|
|
|
|
|
+ if (hOldBitmap == NULL)
|
|
|
{
|
|
{
|
|
|
- SelectObject(m_hMemDC, hOldBitmap);
|
|
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- StretchBlt(hDC, imageRect.left, imageRect.top, imageRect.right - imageRect.left,
|
|
|
|
|
- imageRect.bottom - imageRect.top, m_hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
|
|
|
|
|
|
|
+ StretchBlt(hDC, imageRect.left, imageRect.top, imageWidth, imageHeight,
|
|
|
|
|
+ m_hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
|
|
|
|
|
|
|
|
RECT borderRect = GetVideoBorderDisplayRect(imageRect);
|
|
RECT borderRect = GetVideoBorderDisplayRect(imageRect);
|
|
|
|
|
|
|
@@ -3731,7 +3781,7 @@ void CSettingPageUI::UpdateVideoShow()
|
|
|
HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH));
|
|
HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH));
|
|
|
|
|
|
|
|
Rectangle(hDC, borderRect.left, borderRect.top, borderRect.right, borderRect.bottom);
|
|
Rectangle(hDC, borderRect.left, borderRect.top, borderRect.right, borderRect.bottom);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
HBRUSH hHandleBrush = CreateSolidBrush(RGB(255, 0, 0));
|
|
HBRUSH hHandleBrush = CreateSolidBrush(RGB(255, 0, 0));
|
|
|
auto drawHandle = [&](int x, int y)
|
|
auto drawHandle = [&](int x, int y)
|
|
|
{
|
|
{
|
|
@@ -3743,18 +3793,6 @@ void CSettingPageUI::UpdateVideoShow()
|
|
|
int cx = (borderRect.left + borderRect.right) / 2;
|
|
int cx = (borderRect.left + borderRect.right) / 2;
|
|
|
int cy = (borderRect.top + borderRect.bottom) / 2;
|
|
int cy = (borderRect.top + borderRect.bottom) / 2;
|
|
|
|
|
|
|
|
- /*
|
|
|
|
|
- drawHandle(borderRect.left, borderRect.top);
|
|
|
|
|
- drawHandle(borderRect.right, borderRect.top);
|
|
|
|
|
- drawHandle(borderRect.left, borderRect.bottom);
|
|
|
|
|
- drawHandle(borderRect.right, borderRect.bottom);
|
|
|
|
|
-
|
|
|
|
|
- drawHandle(cx, borderRect.top);
|
|
|
|
|
- drawHandle(cx, borderRect.bottom);
|
|
|
|
|
- drawHandle(borderRect.left, cy);
|
|
|
|
|
- drawHandle(borderRect.right, cy);
|
|
|
|
|
- */
|
|
|
|
|
-
|
|
|
|
|
drawHandle(borderRect.left + 4, borderRect.top + 4);
|
|
drawHandle(borderRect.left + 4, borderRect.top + 4);
|
|
|
drawHandle(borderRect.right - 4, borderRect.top + 4);
|
|
drawHandle(borderRect.right - 4, borderRect.top + 4);
|
|
|
drawHandle(borderRect.left + 4, borderRect.bottom - 4);
|
|
drawHandle(borderRect.left + 4, borderRect.bottom - 4);
|