Page 1 of 1

Bitmap not displaying fast enough

Posted: Wed May 11, 2011 3:53 pm
by Sadbrute
I have an SSTab and i switch between tabs, they each have a picturebox controller (CStatic derived class). I will display the OnPaint Code of the picture box controller:

Code: Select all

 if(hbmp_!=0)
		{
			CRect r;
			CBitmap* m_bitmap=CBitmap::FromHandle(hbmp_);
			
			 CDC dc,*pDC=0;
			
			
		    pDC = this->GetDC();
			dc.CreateCompatibleDC(pDC);
			
			if(m_bitmap!=0 && dc.m_hDC!=NULL)
			{
				 // Select the bitmap into the in-memory DC
				CBitmap* pOldBitmap = dc.SelectObject(m_bitmap);
				pDC->BitBlt(rect_->left,rect_->top,cx_,cy_,&dc, 0, 0, SRCCOPY);
				pDC->SelectObject(pOldBitmap);
				//::DeleteObject(dc);
				m_bitmap->Detach();
				m_bitmap->DeleteObject();
			}
			//dc.ReleaseOutputDC();
			::ReleaseDC(this->m_hWnd,dc);

			::DeleteObject(dc);
			::DeleteObject(pDC);
		}
		else
		{
			CWnd::OnPaint();
		}
But, when i carefully check ,the bottlneck seems to come from here:

Code: Select all

hbmp_ = (HBITMAP)dPlot_GetBitmapEx(DocNum, cxBitmap_, cyBitmap_, &dpm_);

any ideas?


P.S. The slow down comes when i switch a lot ,it might be a memory leak but i'm not creating anything else except what DPLOT gives me ,the HBITMAP.

Posted: Wed May 11, 2011 4:28 pm
by Sadbrute
I seem to leak somewhere,just by switching tabs and drawing the same graph, but i do release the bitmap handles and the Docnum everytime i draw...

Posted: Wed May 11, 2011 5:23 pm
by Sadbrute
I seem to have fixed the speed problem, but after 20 clicks Dplot does not seem to deliver the Bitmap fast enough and makes The onPaint crash. I know it's Dplot because its window kind of "opens up" (well it stays grey) and then the entire screen turns grey....

Posted: Thu May 12, 2011 12:31 pm
by DPlotAdmin
You're welcome to send me your application, preferably with source.

Posted: Thu May 19, 2011 4:26 pm
by Sadbrute
Thx i solved it!

Posted: Thu May 19, 2011 4:34 pm
by DPlotAdmin
If there was a problem you can share here, it might help others. In any case, glad this worked out.

Posted: Fri May 20, 2011 9:39 am
by Sadbrute
It was leaking memory and it caused to "corrupt" my picture boxes.