Click here to Skip to main content
15,904,653 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Need advice on display rotation performance from experienced programmers... Pin
Mark Salsbery7-Mar-07 9:03
Mark Salsbery7-Mar-07 9:03 
GeneralRe: Need advice on display rotation performance from experienced programmers... Pin
CPallini7-Mar-07 9:24
mveCPallini7-Mar-07 9:24 
GeneralRe: Need advice on display rotation performance from experienced programmers... Pin
Mark Salsbery7-Mar-07 9:30
Mark Salsbery7-Mar-07 9:30 
GeneralRe: Need advice on display rotation performance from experienced programmers... Pin
Jun Du7-Mar-07 9:35
Jun Du7-Mar-07 9:35 
GeneralRe: Need advice on display rotation performance from experienced programmers... Pin
Mark Salsbery7-Mar-07 9:44
Mark Salsbery7-Mar-07 9:44 
GeneralRe: Need advice on display rotation performance from experienced programmers... [modified] Pin
Mark Salsbery7-Mar-07 10:25
Mark Salsbery7-Mar-07 10:25 
GeneralRe: Need advice on display rotation performance from experienced programmers... Pin
Jun Du7-Mar-07 16:38
Jun Du7-Mar-07 16:38 
GeneralRe: Need advice on display rotation performance from experienced programmers... Pin
Jun Du8-Mar-07 5:05
Jun Du8-Mar-07 5:05 
I have tested the same thing, but it still eats up ~35% of Dual 3.2GHz CPUs. My code is listed in the following, which basically does the same thing:

void CRotateDlg::OnBnClickedButton1()
{
	// Register custom window
	UINT nClassStyle = CS_OWNDC;

	// Register the tactical display window
	CString m_ClassName = AfxRegisterWndClass (	nClassStyle,							// style
										NULL,									// cursor
										(HBRUSH)GetStockObject(BLACK_BRUSH),	// background
										LoadIcon(NULL, IDI_APPLICATION));		// icon

	//	Create the display window
	LONG winExtStyle = WS_EX_TOPMOST;

	LONG winStyle =	WS_POPUP | WS_VISIBLE | CS_OWNDC;			//	No border, no title bar

	HWND hWnd=::CreateWindowEx(	winExtStyle,
					m_ClassName,
					"",
					winStyle,
					0, 0, 768, 768,
					NULL, NULL, NULL, NULL);

	// 	Create map draw buffer
	CDC *m_pDC = new CDC();
	m_pDC->Attach(::GetDC(hWnd));

	//m_pDC->DrawText("o;ujoeiur", 12, CRect(100, 100, 300, 164), 0);

	CDC *m_pBufferDC = 0;
	CBitmap m_bitmap;

	if(!m_pBufferDC)
	{
		m_pBufferDC = new CDC();
	}	
	m_pBufferDC->CreateCompatibleDC(m_pDC);
	m_bitmap.LoadBitmapA(IDB_BITMAP1);	
	m_pBufferDC->SelectObject(m_bitmap);

	// TODO: Add your control notification handler code here

	double angle = 0.0f;

	for(int i = 0; i < 100; i++)
	{
		// Update angle
		angle += 0.1f;

		// Rotate the drawing surface
		float cosine= (float) cos(DEG2RAD(-angle));
		float sine	= (float) sqrt(1.0 - cosine*cosine);

		m_pDC->SetGraphicsMode(GM_ADVANCED);

		// Get rotation center
		const int xr = 384;
		const int yr = 384;

		XFORM xform = { cosine, sine,		//eM11, eM12
				-sine,	cosine,		//eM21, eM22
				xr-xr*cosine+yr*sine,	//eDx
				yr-yr*cosine-xr*sine};	//eDy

		m_pDC->SetWorldTransform( &xform );

		// Copy the buffer over
		m_pDC->BitBlt(	0, 0, 768, 768,
						m_pBufferDC,
						0, 0,
						SRCCOPY);

		// Reset the drawing sureface
		m_pDC->ModifyWorldTransform(&xform, MWT_IDENTITY);

		Sleep(20);
	}

	m_pDC->Detach();
	delete m_pBufferDC, m_pDC;
}



Best,
Jun

GeneralRe: Need advice on display rotation performance from experienced programmers... Pin
Mark Salsbery8-Mar-07 6:06
Mark Salsbery8-Mar-07 6:06 
GeneralRe: Need advice on display rotation performance from experienced programmers... Pin
Jun Du9-Mar-07 3:28
Jun Du9-Mar-07 3:28 
GeneralRe: Need advice on display rotation performance from experienced programmers... Pin
Mark Salsbery9-Mar-07 11:16
Mark Salsbery9-Mar-07 11:16 
QuestionHow to map message in each item of list control? Pin
Max++7-Mar-07 6:24
Max++7-Mar-07 6:24 
AnswerRe: How to map message in each item of list control? Pin
Hamid_RT7-Mar-07 7:01
Hamid_RT7-Mar-07 7:01 
QuestionC++ XML Transform Pin
Andy H7-Mar-07 6:19
Andy H7-Mar-07 6:19 
AnswerRe: C++ XML Transform Pin
Cedric Moonen7-Mar-07 7:20
Cedric Moonen7-Mar-07 7:20 
JokeRe: C++ XML Transform Pin
Maximilien7-Mar-07 7:24
Maximilien7-Mar-07 7:24 
JokeRe: C++ XML Transform Pin
Cedric Moonen7-Mar-07 7:27
Cedric Moonen7-Mar-07 7:27 
GeneralRe: C++ XML Transform Pin
Maximilien7-Mar-07 7:55
Maximilien7-Mar-07 7:55 
GeneralRe: C++ XML Transform Pin
Andy H7-Mar-07 7:54
Andy H7-Mar-07 7:54 
GeneralRe: C++ XML Transform Pin
Cedric Moonen7-Mar-07 10:33
Cedric Moonen7-Mar-07 10:33 
GeneralRe: C++ XML Transform Pin
Andy H7-Mar-07 11:05
Andy H7-Mar-07 11:05 
QuestionHow to get the local time in seconds? Pin
Yonggoo7-Mar-07 5:35
Yonggoo7-Mar-07 5:35 
AnswerRe: How to get the local time in seconds? Pin
led mike7-Mar-07 5:41
led mike7-Mar-07 5:41 
GeneralRe: How to get the local time in seconds? Pin
Yonggoo7-Mar-07 7:21
Yonggoo7-Mar-07 7:21 
GeneralRe: How to get the local time in seconds? Pin
led mike7-Mar-07 7:36
led mike7-Mar-07 7:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.