Esempio n. 1
0
void CSkinButton::OnPaint() 
{
	if ( !m_res || !m_res->m_bInited )
	{
		Default();
		return;
	}
	//Note:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	// to draw button, cliprgn is needed
	//
	CPaintDC dc(this); // device context for painting
	CRect r;
	CMyBitmap bmp;
	GetClientRect(r);
	DrawImage(bmp);
	SetWindowRgn(bmp.CreateRgnFromFile(RGB(255,0,255)), TRUE );

	
	HRGN hRgn = CreateRectRgn(0, 0, 0, 0);
	GetWindowRgn(hRgn);				
	::SelectClipRgn(dc.GetSafeHdc(), hRgn);
	bmp.Draw( &dc, r );	
	dc.SelectClipRgn(NULL);
	DeleteObject(hRgn);
	
	//dc.BitBlt( 0, 0, r.Width(), r.Height(), &memDC, 0, 0, SRCCOPY);
	DrawText( &dc );

	// TODO: Add your message handler code here
	// Do not call CButton::OnPaint() for painting messages
}
Esempio n. 2
0
// 将OpenCV图像显示到控件上
void	CJudgeDlg::DrawPicture2HDC()
{
	m_matImage = LoadFOVImage2Color(m_pDocument->GetDirectory(), m_nFOVIndex);
	if ( !m_matImage.empty() )
	{
		CArray<CvRect, CvRect>* pRect;
		CvRect cvRect;
		CvPoint pt1, pt2;
		int i;
		//pRect = m_pDocument->GetTargetInfoInFOV(m_nWorkPosition, m_nFOVIndex);
		//for ( i = 0; i < pRect->GetSize(); i++ )
		//{				
		//	cvRect = pRect->GetAt(i);
		//	pt1.x = cvRect.x;
		//	pt1.y = cvRect.y;
		//	pt2.x = cvRect.x + cvRect.width;
		//	pt2.y = cvRect.y + cvRect.height;
		//	cvRectangle(m_pcvImage, pt1, pt2, CV_RGB(255,0,0), 2, 8,0);
		//}
				
		pRect = m_pDocument->GetSimpleTargetInfoInFOV(m_nFOVIndex);
		for ( i = 0; i < pRect->GetSize(); i++ )
		{				
			cvRect = pRect->GetAt(i);
			pt1.x = cvRect.x;
			pt1.y = cvRect.y;
			pt2.x = cvRect.x + cvRect.width;
			pt2.y = cvRect.y + cvRect.height;
			cv::rectangle(m_matImage, pt1, pt2, CV_RGB(255,0,0), 2, 8,0);
		}
		pRect = m_pDocument->GetOverlapTargetInfoInFOV( m_nFOVIndex);
		for ( i = 0; i < pRect->GetSize(); i++ )
		{				
			cvRect = pRect->GetAt(i);
			pt1.x = cvRect.x;
			pt1.y = cvRect.y;
			pt2.x = cvRect.x + cvRect.width;
			pt2.y = cvRect.y + cvRect.height;
			cv::rectangle(m_matImage, pt1, pt2, CV_RGB(0,255,0), 2, 8,0);
		}

		UINT ID = IDC_FOV_IMAGE;
		
		CDC *pDC = this->GetDlgItem(ID)->GetDC();
		HDC hDC = pDC->GetSafeHdc();

		CRect	rect;
		this->GetDlgItem(ID)->GetClientRect(&rect);
		
		CMyBitmap bmp;
		bmp.CopyFromMat(m_matImage);
		bmp.Draw(hDC,rect,1,0,0);

		ReleaseDC(pDC);	
	}	
}