Bitmap not displaying fast enough

Q&A for C, C++, and/or C# developers using DPlot
Post Reply
Sadbrute
Posts: 14
Joined: Tue Apr 26, 2011 6:06 pm

Bitmap not displaying fast enough

Post 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.
Sadbrute
Posts: 14
Joined: Tue Apr 26, 2011 6:06 pm

Post 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...
Sadbrute
Posts: 14
Joined: Tue Apr 26, 2011 6:06 pm

Post 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....
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

You're welcome to send me your application, preferably with source.
Visualize Your Data
support@dplot.com
Sadbrute
Posts: 14
Joined: Tue Apr 26, 2011 6:06 pm

Post by Sadbrute »

Thx i solved it!
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

If there was a problem you can share here, it might help others. In any case, glad this worked out.
Visualize Your Data
support@dplot.com
Sadbrute
Posts: 14
Joined: Tue Apr 26, 2011 6:06 pm

Post by Sadbrute »

It was leaking memory and it caused to "corrupt" my picture boxes.
Post Reply