Click here to Skip to main content
15,915,600 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: GDI+ DrawImage() Speed Issue Pin
Nishad S19-Feb-09 23:55
Nishad S19-Feb-09 23:55 
GeneralRe: GDI+ DrawImage() Speed Issue Pin
Redeye9220-Feb-09 0:15
Redeye9220-Feb-09 0:15 
GeneralRe: GDI+ DrawImage() Speed Issue Pin
Nishad S20-Feb-09 0:29
Nishad S20-Feb-09 0:29 
GeneralRe: GDI+ DrawImage() Speed Issue Pin
Redeye9220-Feb-09 0:54
Redeye9220-Feb-09 0:54 
AnswerRe: GDI+ DrawImage() Speed Issue Pin
Stuart Dootson20-Feb-09 2:40
professionalStuart Dootson20-Feb-09 2:40 
GeneralThe Solution Pin
Redeye9220-Feb-09 3:29
Redeye9220-Feb-09 3:29 
GeneralRe: The Solution Pin
micahferguson28-Feb-09 9:53
micahferguson28-Feb-09 9:53 
GeneralRe: The Solution Pin
Redeye921-Mar-09 21:46
Redeye921-Mar-09 21:46 
Not at all...

In OnPaint()
<br />
        // Get a device context for painting<br />
	CPaintDC dc(this);<br />
	if(!m_pMemDC)<br />
	{<br />
		vUpdateBitmap(&dc);<br />
	}<br />
	// Get the client rect<br />
	CRect rcClientRect;<br />
	GetClientRect(&rcClientRect);<br />
        // Get the actual width of the view we want to draw<br />
	ULONG32 ulViewWidth = ulGetViewWidth();<br />
	// If the window size has changed for any reason, we need to redraw the bitmap<br />
        // Put your if statement here.<br />
	{<br />
		vUpdateBitmap(&dc);<br />
	}<br />
	// Get the invalid rectangle<br />
	CRect rcPaint;<br />
	dc.GetClipBox(rcPaint);<br />
	// Then just copy the bit of the memory bitmap that we need<br />
	dc.BitBlt(rcPaint.left, rcPaint.top, rcPaint.Width(), rcPaint.Height(),<br />
		m_pMemDC, rcPaint.left, rcPaint.top, SRCCOPY);<br />


The vUpdateBitmap function:
<br />
<br />
		// Recreate the memory bitmap and graphics objects<br />
		if(pDC)<br />
		{<br />
			if(m_pMemDC)<br />
			{<br />
				delete m_pMemDC;<br />
			}<br />
			m_pMemDC = new CDC;<br />
			// Make a compatible DC<br />
			m_pMemDC->CreateCompatibleDC(pDC);;<br />
			<br />
			// Create a new bitmap<br />
			CBitmap *m_pNewBitmap;<br />
			m_pNewBitmap = new CBitmap;<br />
			// Create the new bitmap<br />
			m_pNewBitmap->CreateCompatibleBitmap(pDC, rcClient.Width(), rcClient.Height());<br />
			m_pNewBitmap->SetBitmapDimension(rcClient.Width(), rcClient.Height());<br />
			// Select the new bitmap into the memory DC<br />
			m_pMemDC->SelectObject(m_pNewBitmap);<br />
			// Delete the old one<br />
			delete m_pbmpMemBitmap;<br />
			// Reset the view pointer<br />
			m_pbmpMemBitmap = m_pNewBitmap;<br />
			if(m_gr)<br />
			{ delete m_gr; }<br />
			m_gr = Graphics::FromHDC(m_pMemDC->m_hDC);<br />
		}<br />


Then you can use the m_gr Graphics object to do your GDI+ drawing to the offscreen bitmap and the actual screen draw is done by the much faster BitBlt.

Hope that helps
QuestionAttempting to get 'Desktop PIDL' on Win2k, Win98 - Bizarre behavior Pin
ab4rum19-Feb-09 21:03
ab4rum19-Feb-09 21:03 
AnswerRe: Attempting to get 'Desktop PIDL' on Win2k, Win98 - Bizarre behavior Pin
Stuart Dootson20-Feb-09 2:59
professionalStuart Dootson20-Feb-09 2:59 
Questionhow to set sound output in left or right side of headphone? Pin
nekokan19-Feb-09 20:06
nekokan19-Feb-09 20:06 
AnswerRe: how to set sound output in left or right side of headphone? Pin
Nishad S20-Feb-09 0:00
Nishad S20-Feb-09 0:00 
QuestionRenaming solution file in vc++ Pin
priyankapriyanka19-Feb-09 19:04
priyankapriyanka19-Feb-09 19:04 
AnswerREPOST: ANSWERED Yesterday! Pin
_AnsHUMAN_ 19-Feb-09 19:13
_AnsHUMAN_ 19-Feb-09 19:13 
AnswerRe: Renaming solution file in vc++ Pin
Chandrasekharan P19-Feb-09 19:32
Chandrasekharan P19-Feb-09 19:32 
GeneralRe: Renaming solution file in vc++ Pin
priyankapriyanka19-Feb-09 22:30
priyankapriyanka19-Feb-09 22:30 
GeneralRe: Renaming solution file in vc++ Pin
Chandrasekharan P19-Feb-09 23:43
Chandrasekharan P19-Feb-09 23:43 
AnswerIt's also time to rename your post. Pin
CPallini19-Feb-09 21:53
mveCPallini19-Feb-09 21:53 
Questionlogging optimization. Pin
vikramlinux19-Feb-09 19:00
vikramlinux19-Feb-09 19:00 
AnswerRe: logging optimization. Pin
KarstenK19-Feb-09 23:24
mveKarstenK19-Feb-09 23:24 
AnswerRe: logging optimization. Pin
Nishad S20-Feb-09 0:03
Nishad S20-Feb-09 0:03 
GeneralRe: logging optimization. Pin
vikramlinux25-Feb-09 18:23
vikramlinux25-Feb-09 18:23 
GeneralRe: logging optimization. Pin
Nishad S25-Feb-09 19:04
Nishad S25-Feb-09 19:04 
Questionmsnp 15 contact management source code Pin
amit090219-Feb-09 17:55
amit090219-Feb-09 17:55 
AnswerRe: msnp 15 contact management source code Pin
Cedric Moonen19-Feb-09 20:21
Cedric Moonen19-Feb-09 20:21 

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.