Ejemplo n.º 1
0
	void Zoom(double zoomFactor)
	{
		if (zoomFactor < 0.05)
		{
			zoomFactor = 0.05;
		}
		if (zoomFactor > 5)
		{
			zoomFactor = 5;
		}
		m_zoomFactor = zoomFactor;

		wxRect currentImageRect = GetImageRect();

		wxSize clientSize = GetClientSize();
		int scrollX = currentImageRect.width + 10 > clientSize.x ?
			(currentImageRect.width - clientSize.x) : 0;
		int scrollY = currentImageRect.height + 10 > clientSize.y ?
			(currentImageRect.height - clientSize.y) : 0;

		SetVirtualSize(currentImageRect.width + 10, currentImageRect.height + 10);
		Scroll(scrollX / 2, scrollY / 2);

		Refresh();
	}
//not using hole traffic ligh as samples,just use the square light
int RecognizeLight(IplImage* srcImg,CvRect iRect)
{
	CvSize cutSize;
	cutSize.width=iRect.width;
	cutSize.height=iRect.height;
	IplImage *tmpCutImg=cvCreateImage(cutSize,srcImg->depth,srcImg->nChannels);
	GetImageRect(srcImg,iRect,tmpCutImg);
#if IS_CUTIMG
	cvShowImage("tmpCutImg",tmpCutImg);
	cvWaitKey(1);
	char tmpName[100];
	static int ppp=0;
	ppp++;
	sprintf_s(tmpName,"ImgCut//%d.jpg",ppp);
	cvSaveImage(tmpName,tmpCutImg);
#endif

	Mat cutMat(tmpCutImg);
	Mat tmpTLRec;
	vector<float> descriptor;

	//识别信号灯类别
	resize(cutMat,tmpTLRec,Size(TLREC_WIDTH,TLREC_HEIGHT));
	TLRecHOG.compute(tmpTLRec,descriptor,Size(8,8));
	int DescriptorDim=descriptor.size();		
	Mat SVMTLRecMat(1,DescriptorDim,CV_32FC1);
	for(int i=0; i<DescriptorDim; i++)
		SVMTLRecMat.at<float>(0,i) = descriptor[i];

	int result=TLRecSVM.predict(SVMTLRecMat);
	cvReleaseImage(&tmpCutImg);
	return result;
}
Ejemplo n.º 3
0
LRESULT CView::OnWindowPosChanged(WPARAM /*wParam*/, LPARAM /*lParam*/)
{
	if (m_pPicture)
	{
		CRect rcImage = GetImageRect();
		DWORD dwStyle = (DWORD)GetWindowLongPtr(GWL_STYLE);
		DWORD dwExStyle = (DWORD)GetWindowLongPtr(GWL_EXSTYLE);
		AdjustWindowRectEx(&rcImage, dwStyle, FALSE, dwExStyle);

		CRect rcView = GetClientRect();
		AdjustWindowRectEx(&rcView, dwStyle, FALSE, dwExStyle);

		SCROLLINFO si;
		ZeroMemory(&si, sizeof(SCROLLINFO));
		si.cbSize = sizeof(si);
		si.fMask  = SIF_RANGE | SIF_PAGE | SIF_POS;
		si.nMin   = 0;

		if (rcView.Width()  >= rcImage.Width())
		{
			m_xCurrentScroll = 0;
			ShowScrollBar(SB_HORZ, FALSE);
		}
		else
		{
			si.nMax   = rcImage.Width();
			si.nPage  = rcView.Width();
			si.nPos   = m_xCurrentScroll;
			SetScrollInfo(SB_HORZ, si, TRUE);
			ShowScrollBar(SB_HORZ, TRUE);
		}

		if (rcView.Height() >= rcImage.Height())
		{
			m_yCurrentScroll = 0;
			ShowScrollBar(SB_VERT, FALSE);
		}
		else
		{
			si.nMax   = rcImage.Height();
			si.nPage  = rcView.Height();
			si.nPos   = m_yCurrentScroll;
			SetScrollInfo(SB_VERT, si, TRUE);
			ShowScrollBar(SB_VERT, TRUE);
		}

		int xNewPos = MIN(m_xCurrentScroll, rcImage.Width() - rcView.Width());
		m_xCurrentScroll = MAX(xNewPos, 0);
		int yNewPos = MIN(m_yCurrentScroll, rcImage.Height() - rcView.Height());
		m_yCurrentScroll = MAX(yNewPos, 0);

		// Paint the window directly to eliminate flicker
		CClientDC dcView(this);
		Paint(dcView);
	}

	return 0L;
}
Ejemplo n.º 4
0
LRESULT CView::OnVScroll(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	UNREFERENCED_PARAMETER(uMsg);
	UNREFERENCED_PARAMETER(lParam);

	int yNewPos;

	switch (LOWORD(wParam))
	{
		case SB_PAGEUP: // User clicked the scroll bar shaft above the scroll box.
			yNewPos = m_yCurrentScroll - 50;
			break;

		case SB_PAGEDOWN: // User clicked the scroll bar shaft below the scroll box.
			yNewPos = m_yCurrentScroll + 50;
			break;

		case SB_LINEUP: // User clicked the top arrow.
			yNewPos = m_yCurrentScroll - 5;
			break;

		case SB_LINEDOWN: // User clicked the bottom arrow.
			yNewPos = m_yCurrentScroll + 5;
			break;

		case SB_THUMBPOSITION: // User dragged the scroll box.
			yNewPos = HIWORD(wParam);
			break;

		case SB_THUMBTRACK: // User dragging the scroll box.
			yNewPos = HIWORD(wParam);
			break;

		default:
			yNewPos = m_yCurrentScroll;
	}

	// Scroll the window.
	yNewPos = MAX(0, yNewPos);
	yNewPos = MIN( yNewPos, GetImageRect().Height() - GetClientRect().Height() );
	int yDelta = yNewPos - m_yCurrentScroll;
	m_yCurrentScroll = yNewPos;
	ScrollWindowEx(0, -yDelta, NULL, NULL, NULL, NULL, SW_INVALIDATE);

	// Reset the scroll bar.
	SCROLLINFO si;
	ZeroMemory(&si, sizeof(SCROLLINFO));
	si.cbSize = sizeof(si);
	si.fMask  = SIF_RANGE | SIF_PAGE | SIF_POS;
	si.cbSize = sizeof(si);
	si.fMask  = SIF_POS;
	si.nPos   = m_yCurrentScroll;
	SetScrollInfo(SB_VERT, si, TRUE);

	return 0;
}
Ejemplo n.º 5
0
	void SetViewSize(int viewWidth, int viewHeight)
	{
		wxRect oldImageRect = GetImageRect();

		m_viewSize = wxSize(viewWidth, viewHeight);

		wxSize zoomedSize((int)(viewWidth * m_zoomFactor), (int)(viewHeight * m_zoomFactor));
		wxSize virtualSize = GetVirtualSize();
		if (virtualSize.x != zoomedSize.GetWidth() + 10
			|| virtualSize.y != zoomedSize.GetHeight() + 10)
		{
			SetVirtualSize(zoomedSize.GetWidth() + 10, zoomedSize.GetHeight() + 10);
		}

		wxRect imageRect = GetImageRect();
		imageRect = imageRect.Union(oldImageRect);

		Refresh(false, &imageRect);
	}
Ejemplo n.º 6
0
LRESULT CView::OnHScroll(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	UNREFERENCED_PARAMETER(uMsg);
	UNREFERENCED_PARAMETER(lParam);

	int xNewPos;

	switch (LOWORD(wParam))
	{
		case SB_PAGEUP: // User clicked the scroll bar shaft left of the scroll box.
			xNewPos = m_xCurrentScroll - 50;
			break;

		case SB_PAGEDOWN: // User clicked the scroll bar shaft right of the scroll box.
			xNewPos = m_xCurrentScroll + 50;
			break;

		case SB_LINEUP: // User clicked the left arrow.
			xNewPos = m_xCurrentScroll - 5;
			break;

		case SB_LINEDOWN: // User clicked the right arrow.
			xNewPos = m_xCurrentScroll + 5;
			break;

		case SB_THUMBPOSITION: // User dragged the scroll box.
			xNewPos = HIWORD(wParam);
			break;

		case SB_THUMBTRACK: // User dragging the scroll box.
			xNewPos = HIWORD(wParam);
			break;

		default:
			xNewPos = m_xCurrentScroll;
	}

	// Scroll the window.
	xNewPos = MAX(0, xNewPos);
	xNewPos = MIN( xNewPos, GetImageRect().Width() - GetClientRect().Width() );
	int xDelta = xNewPos - m_xCurrentScroll;
	m_xCurrentScroll = xNewPos;
	ScrollWindowEx(-xDelta, 0,  NULL, NULL, NULL, NULL, SW_INVALIDATE);

	// Reset the scroll bar.
	SCROLLINFO si;
	ZeroMemory(&si, sizeof(SCROLLINFO));
	si.cbSize = sizeof(si);
	si.fMask  = SIF_RANGE | SIF_PAGE | SIF_POS;
	si.fMask  = SIF_POS;
	si.nPos   = m_xCurrentScroll;
	SetScrollInfo(SB_HORZ, si, TRUE);

	return 0L;
}
Ejemplo n.º 7
0
bool ctrlImage::Msg_MouseMove(const MouseCoords& mc)
{
    // gültiges Bild?
    if(GetImage())
    {
        // Jeweils Tooltip ein- und ausblenden, wenn die Maus über dem Bild ist
        if(IsPointInRect(mc.GetPos(), Rect::move(GetImageRect(), GetDrawPos())))
            ShowTooltip();
        else
            HideTooltip();
    }

    return false;
}
Ejemplo n.º 8
0
BOOL CImage::GetMaskRect(LPRECT lpRect)
{
	LPMASK lpMask;

	if (lpMask = GetMask())
   	{
    	MaskRect(lpMask, lpRect);
    	return(TRUE);
   	}
	else
   	{
    	GetImageRect(lpRect);
    	return(FALSE);
   	}
}
int isTL(IplImage* srcImg,CvRect iRect,bool isVertical)
{
	CvSize cutSize;
	cutSize.width=iRect.width;
	cutSize.height=iRect.height;
	IplImage *tmpCutImg=cvCreateImage(cutSize,srcImg->depth,srcImg->nChannels);
	GetImageRect(srcImg,iRect,tmpCutImg);

	Mat cutMat(tmpCutImg);
	Mat tmpIsTL;
	vector<float> descriptor;

	//识别信号灯类别
	if (isVertical){
		resize(cutMat, tmpIsTL, Size(HOG_TLVertical_Width, HOG_TLVertical_Height));
		myHOG_vertical.compute(tmpIsTL, descriptor, Size(8, 8));
	}
	else{
		resize(cutMat, tmpIsTL, Size(HOG_TLHorz_Width, HOG_TLHorz_Height));
		myHOG_horz.compute(tmpIsTL, descriptor, Size(8, 8));
	}
		
	int DescriptorDim=descriptor.size();		
	Mat SVMTLRecMat(1,DescriptorDim,CV_32FC1);
	for(int i=0; i<DescriptorDim; i++)
		SVMTLRecMat.at<float>(0,i) = descriptor[i];

	//int result=isTLSVM.predict(SVMTLRecMat);
	int result = 0;
	if (isVertical)
		result = isVerticalTLSVM.predict(SVMTLRecMat);
	else
	{
		result = isHorzTLSVM.predict(SVMTLRecMat);
	}
	cvReleaseImage(&tmpCutImg);
	return result;
}
void rectangleDetection(IplImage* inputImage,IplImage* srcImage,CvRect iRect,int iColor,vector<ShapeRecResult> &v)//p1为前行位,p2为左转位
{
	const int iWidth = inputImage->width;
	const int iHeight = inputImage->height;
	
	//水平和竖直状态
	//bool VerticalReturnStatus = false;
	//bool HorzReturnStatus=false;

	//横向检测框
	int HorzRectHeight=(iRect.width+iRect.height)/2 + 6;
	int HorzRectWidth=3*(HorzRectHeight-4)+3;
	int HorzRectX1=0, HorzRectY1=0;
	int HorzRectX2=0, HorzRectY2=0;


	//thresholding for graylevel differences between seedpoints and its neibours
	const int grayThresholding =80;//70
	const int RatioThreshold =  55;//检测框中黑色像素所占比例

	//纵向检测框
	//int iDrawRectWidth = (iRect.width+iRect.height)/2 + 6;
	int iDrawRectWidth = (iRect.width + iRect.height)/2 *5/ 3;
	//int iDrawRectHeight = 3*(iDrawRectWidth-4)+6;
	int iDrawRectHeight;
	int iDrawRectX1=0, iDrawRectY1=0;
	int iDrawRectX2=0, iDrawRectY2=0;

	if(iColor==RED_PIXEL_LABEL){
		iDrawRectHeight = iDrawRectWidth * 7 / 3;
		iDrawRectY1 = iRect.y - iDrawRectWidth /4;
		HorzRectX1= iRect.x-3;
		///iDrawRectHeight = iDrawRectWidth * 7 / 3;
	}
	else if(iColor == GREEN_PIXEL_LABEL){
		iDrawRectHeight = iDrawRectWidth * 8 / 3;
		iDrawRectY1 = iRect.y-iDrawRectHeight/3*2;
		HorzRectX1=iRect.x-HorzRectWidth/3*2;
	}

	//竖直检测窗设置
	iDrawRectY2 = iDrawRectY1 + iDrawRectHeight;
	iDrawRectX1 = iRect.x - iDrawRectWidth/5;
	iDrawRectX2 = iDrawRectX1 + iDrawRectWidth;

	//水平检测框设置
	HorzRectX2= HorzRectX1+HorzRectWidth;
	HorzRectY1= iRect.y-3;
	HorzRectY2= HorzRectY1+HorzRectHeight;

	if(HorzRectX1<0 || HorzRectY1<0 || HorzRectX2>=iWidth || HorzRectY2>=iHeight)
	{
		//cvReleaseImage(&imageGrayScale);//when return the result, the image must be released, otherwise,the memory will be leaked
		return;
	}
	
	if( iDrawRectX1<0 || iDrawRectY1<0 || iDrawRectX2>=iWidth || iDrawRectY2>=iHeight)
	{
		//cvReleaseImage(&imageGrayScale);//when return the result, the image must be released, otherwise,the memory will be leaked
		return;
	}


	//竖直方向统计黑色像素比例
	CvRect VerticalRect;
	VerticalRect.x=iDrawRectX1;
	VerticalRect.y=iDrawRectY1;
	VerticalRect.width=iDrawRectWidth;
	VerticalRect.height=iDrawRectHeight;
	IplImage*VerticalLight = cvCreateImage(cvSize(iDrawRectWidth,iDrawRectHeight),srcImage->depth,srcImage->nChannels);
	GetImageRect(srcImage,VerticalRect,VerticalLight);
	IplImage *VerticalGrayLight=cvCreateImage(cvSize(iDrawRectWidth,iDrawRectHeight),IPL_DEPTH_8U,1);
	cvCvtColor(VerticalLight,VerticalGrayLight,CV_BGR2GRAY);
	cvThreshold(VerticalGrayLight,VerticalGrayLight,0,255,CV_THRESH_OTSU);
	
	//get the other two  blocks black ration (vertical)
	bool verticalBlackLimit = checkOtherBlocksBlackRatio(VerticalGrayLight, iColor,true);

	ShapeRecResult TLbox;
	//若检测出的矩形框符合条件,则将坚持到的矩形框放入v中,在外面统一显示
	//if(VerticalBlackRatio>=RatioThreshold&&VerticalBlackRatio<=93)
	//if (verticalBlackLimit&&isTL(srcImage, VerticalRect, true)){
	if (verticalBlackLimit == true && isTL(srcImage, VerticalRect, true))
	{
		TLbox.box = VerticalRect;
		//TLbox.shape = 1;//表示竖向

		if (iColor == GREEN_PIXEL_LABEL)
		{
			//cvRectangle(srcImage,cvPoint(iDrawRectX1,iDrawRectY1),cvPoint(iDrawRectX2,iDrawRectY2),cvScalar(0,255,0),2);
			TLbox.color = GREEN_PIXEL_LABEL;
			v.push_back(TLbox);
		}

		else if (iColor == RED_PIXEL_LABEL)
		{
			//cvRectangle(srcImage,cvPoint(iDrawRectX1,iDrawRectY1),cvPoint(iDrawRectX2,iDrawRectY2),cvScalar(0,0,255),2);
			TLbox.color = RED_PIXEL_LABEL;

			//识别信号灯指向
			int result = RecognizeLight(srcImage, iRect);
			switch (result)
			{
			case 0://圆形
				TLbox.shape = 0;
				break;
			case 1://禁止左转
				TLbox.shape = 1;
				break;
			case 2://前行箭头
				TLbox.shape = 0;
				break;
			default:
				break;
			}
			v.push_back(TLbox);
		}
	}
	else{
		//水平方向统计黑色像素比例
		CvRect HorzRect;
		HorzRect.x = HorzRectX1;
		HorzRect.y = HorzRectY1;
		HorzRect.width = HorzRectWidth;
		HorzRect.height = HorzRectHeight;
		IplImage*HorzLight = cvCreateImage(cvSize(HorzRectWidth, HorzRectHeight), srcImage->depth, srcImage->nChannels);
		GetImageRect(srcImage, HorzRect, HorzLight);
		IplImage *HorzGrayLight = cvCreateImage(cvSize(HorzRectWidth, HorzRectHeight), IPL_DEPTH_8U, 1);
		cvCvtColor(HorzLight, HorzGrayLight, CV_BGR2GRAY);
		cvThreshold(HorzGrayLight, HorzGrayLight, 0, 255, CV_THRESH_OTSU);


		/*
		int HorzWidthStep = HorzGrayLight->widthStep;
		int HorzSum=0;
		int HorzGrayValue=0;
		unsigned char* pDataHorz;
		for(int j=0; j<HorzRectHeight; j++){
		pDataHorz = (unsigned char*)HorzGrayLight->imageData + j*HorzWidthStep;
		for(int i=0; i<HorzRectWidth; i++){
		HorzGrayValue = pDataHorz[i];
		//if((HorzGrayValue<=grayThresholding))
		if((HorzGrayValue==0))
		HorzSum++;
		}
		}	*/
		/*int cvHorzSum=cvCountNonZero(HorzGrayLight);
		int horzBlackNum=HorzRectWidth*HorzRectHeight-cvHorzSum;*/

		//get the other two  blocks black ration (horizental)
		bool horizBlackLimit = checkOtherBlocksBlackRatio(HorzGrayLight, iColor, false);
		//bool horizBlackLimit = true;

		//else if (HorzBlackRatio>=RatioThreshold&&HorzBlackRatio<=90)
		//else if (horizBlackLimit&&isTL(srcImage, HorzRect, false))
		if (horizBlackLimit&&isTL(srcImage, HorzRect, false))
		{
			//横向检测
			TLbox.box.x = HorzRectX1;
			TLbox.box.y = HorzRectY1;
			TLbox.box.width = HorzRectWidth;
			TLbox.box.height = HorzRectHeight;
			//TLbox.shape = 0;//表示横向



			if (iColor == GREEN_PIXEL_LABEL)
			{
				//cvRectangle(srcImage,cvPoint(HorzRectX1,HorzRectY1),cvPoint(HorzRectX2,HorzRectY2),cvScalar(0,255,0),2);
				TLbox.color = GREEN_PIXEL_LABEL;
				v.push_back(TLbox);
			}

			else if (iColor == RED_PIXEL_LABEL)
			{
				//cvRectangle(srcImage,cvPoint(HorzRectX1,HorzRectY1),cvPoint(HorzRectX2,HorzRectY2),cvScalar(0,0,255),2);
				//*p1=*p1+1;
				TLbox.color = RED_PIXEL_LABEL;
				int result = RecognizeLight(srcImage, iRect);
				switch (result)
				{
				case 0://圆形
					TLbox.shape = 0;
					break;
				case 1://禁止左转
					TLbox.shape = 1;
					break;
				case 2://前行箭头
					TLbox.shape = 0;
					break;
				default:
					break;
				}
				v.push_back(TLbox);
			}
		}
		cvReleaseImage(&HorzLight);
		cvReleaseImage(&HorzGrayLight);
	}





	

	/*
	int iWidthStep = VerticalGrayLight->widthStep; 
	int sum=0;
	int VerticalGrayValue=0;
	unsigned char* pDataVertical;
	for(int j=0; j<iDrawRectHeight; j++){
		pDataVertical = (unsigned char*)VerticalGrayLight->imageData + j*iWidthStep;
		for(int i=0; i<iDrawRectWidth; i++){
			VerticalGrayValue = pDataVertical[i];
			if((VerticalGrayValue<=grayThresholding))
				sum++;
		}
	}*/	

	//int cvVerticalSum=cvCountNonZero(VerticalGrayLight);
	//int verticalBlackNum=iDrawRectWidth*iDrawRectHeight-cvVerticalSum;//黑色像素点个数
	



	

	//int VerticalBlackRatio = (float)verticalBlackNum*100/(float)((iDrawRectWidth+1)*((float)iDrawRectHeight+1));//矩形框中黑色像素所占比例
	//int HorzBlackRatio=(float)horzBlackNum*100/(float)((HorzRectWidth+1)*((float)HorzRectHeight+1));//矩形框中黑色像素所占比例
	
#if ISDEBUG_TL
	ofstream outfile;
	outfile.open(debugTLPath,ios::app);//ios::app: 以追加的方式打开文件
	outfile<<"===black VerticalBlackRatio===:"<<VerticalBlackRatio<<endl;//输出到调试文件中
	cout<<"===black VerticalBlackRatio===:"<<VerticalBlackRatio<<endl;//输出到控制台
	outfile.close();
#endif

#if ISDEBUG_TL
	Mat grayMat(imageGrayScale);
	Rect drawRect;
	drawRect.x=iDrawRectX1;
	drawRect.y=iDrawRectY1;
	drawRect.width=iDrawRectX2-iDrawRectX1;
	drawRect.height=iDrawRectY2-iDrawRectY1;
	Mat tmpMat=grayMat(drawRect);
	isLighInBox(tmpMat);
#endif

	//int DetectResult=isTL(srcImage,iRect,);
	//int DetectResult = isTL(srcImage, VerticalRect);

	cvReleaseImage(&VerticalLight);
	cvReleaseImage(&VerticalGrayLight);
	

	//DetectResult = 1;

	return;
}
Ejemplo n.º 11
0
// More efficient: erase and redraw simultaneously if possible
bool wxGenericDragImage::RedrawImage(const wxPoint& oldPos,
                                     const wxPoint& newPos,
                                     bool eraseOld, bool drawNew)
{
    if (!m_windowDC)
        return false;

#ifdef wxHAS_NATIVE_OVERLAY
    wxUnusedVar(oldPos);

    wxDCOverlay dcoverlay( m_overlay, (wxWindowDC*) m_windowDC ) ;
    if ( eraseOld )
        dcoverlay.Clear() ;
    if (drawNew)
        DoDrawImage(*m_windowDC, newPos);
#else // !wxHAS_NATIVE_OVERLAY
    wxBitmap* backing = (m_pBackingBitmap ? m_pBackingBitmap : (wxBitmap*) & m_backingBitmap);
    if (!backing->IsOk())
        return false;

    wxRect oldRect(GetImageRect(oldPos));
    wxRect newRect(GetImageRect(newPos));

    wxRect fullRect;

    // Full rect: the combination of both rects
    if (eraseOld && drawNew)
    {
        int oldRight = oldRect.GetRight();
        int oldBottom = oldRect.GetBottom();
        int newRight = newRect.GetRight();
        int newBottom = newRect.GetBottom();

        wxPoint topLeft = wxPoint(wxMin(oldPos.x, newPos.x), wxMin(oldPos.y, newPos.y));
        wxPoint bottomRight = wxPoint(wxMax(oldRight, newRight), wxMax(oldBottom, newBottom));

        fullRect.x = topLeft.x; fullRect.y = topLeft.y;
        fullRect.SetRight(bottomRight.x);
        fullRect.SetBottom(bottomRight.y);
    }
    else if (eraseOld)
        fullRect = oldRect;
    else if (drawNew)
        fullRect = newRect;

    // Make the bitmap bigger than it need be, so we don't
    // keep reallocating all the time.
    int excess = 50;

    if (!m_repairBitmap.IsOk() || (m_repairBitmap.GetWidth() < fullRect.GetWidth() || m_repairBitmap.GetHeight() < fullRect.GetHeight()))
    {
        m_repairBitmap = wxBitmap(fullRect.GetWidth() + excess, fullRect.GetHeight() + excess);
    }

    wxMemoryDC memDC;
    memDC.SelectObject(* backing);

    wxMemoryDC memDCTemp;
    memDCTemp.SelectObject(m_repairBitmap);

    // Draw the backing bitmap onto the repair bitmap.
    // If full-screen, we may have specified the rect on the
    // screen that we're using for our backing bitmap.
    // So subtract this when we're blitting from the backing bitmap
    // (translate from screen to backing-bitmap coords).

    memDCTemp.Blit(0, 0, fullRect.GetWidth(), fullRect.GetHeight(), & memDC, fullRect.x - m_boundingRect.x, fullRect.y - m_boundingRect.y);

    // If drawing, draw the image onto the mem DC
    if (drawNew)
    {
        wxPoint pos(newPos.x - fullRect.x, newPos.y - fullRect.y) ;
        DoDrawImage(memDCTemp, pos);
    }

    // Now blit to the window
    // Finally, blit the temp mem DC to the window.
    m_windowDC->Blit(fullRect.x, fullRect.y, fullRect.width, fullRect.height, & memDCTemp, 0, 0);

    memDCTemp.SelectObject(wxNullBitmap);
    memDC.SelectObject(wxNullBitmap);
#endif // wxHAS_NATIVE_OVERLAY/!wxHAS_NATIVE_OVERLAY

    return true;
}
Ejemplo n.º 12
0
void CButtonBarDisplay::Paint (CG32bitImage &Dest)

//	Paint
//
//	Paint the bar

	{
	int i;

	//	Fill background

	Dest.Fill(m_rcRect.left,
			m_rcRect.top,
			RectWidth(m_rcRect),
			RectHeight(m_rcRect),
			BAR_COLOR);

	//	Get the images

	const CG32bitImage &Images = m_pButtons->GetImage();

	//	Paint each button

	for (i = 0; i < m_pButtons->GetCount(); i++)
		{
		RECT rcRect = m_pButtons->GetButtonRect(i);

		//	Skip invisible buttons

		if (!m_pButtons->GetVisible(i))
			continue;

		//	Paint the image

		RECT rcSrc;
		GetImageRect(i, (i == m_iSelected), &rcSrc);

		Dest.Blt(rcSrc.left,
				rcSrc.top,
				RectWidth(rcSrc),
				RectHeight(rcSrc),
				Images,
				rcRect.left,
				rcRect.top);

		//	Paint the button label

		int cxWidth = m_pFonts->SubTitle.MeasureText(m_pButtons->GetLabel(i), NULL);
		m_pFonts->SubTitle.DrawText(Dest,
				rcRect.left + (RectWidth(rcRect) - cxWidth) / 2,
				rcRect.top + BUTTON_LABEL_Y,
				CG32bitPixel(128,128,128),
				m_pButtons->GetLabel(i));

		//	Paint the description

		cxWidth = m_pFonts->Medium.MeasureText(m_pButtons->GetDescription(i), NULL);
		m_pFonts->Medium.DrawText(Dest,
				rcRect.left + (RectWidth(rcRect) - cxWidth) / 2,
				rcRect.top + BUTTON_DESCRIPTION_Y,
				CG32bitPixel(255,255,255),
				m_pButtons->GetDescription(i));
		}
	}