CPaintDC develish slow
-
Hi all, I am currently doing a project where I need to be able to have a imaging framework. Although the framework itself runs pretty smooth, the CPaintDC of MFC kills me. The SetPixelV is extremely slow, so I want to use another way of doing this. I know it is possible to create a CDC in memory, but how can I put a bitmap created from this CDC put on the surface a CWnd subclassed control? Any suggestions? LPCTSTR Dutch = TEXT("Double Dutch :-)");
-
Hi all, I am currently doing a project where I need to be able to have a imaging framework. Although the framework itself runs pretty smooth, the CPaintDC of MFC kills me. The SetPixelV is extremely slow, so I want to use another way of doing this. I know it is possible to create a CDC in memory, but how can I put a bitmap created from this CDC put on the surface a CWnd subclassed control? Any suggestions? LPCTSTR Dutch = TEXT("Double Dutch :-)");
bitblt. Code snippet to help you (heavily edited and content deleted):
BOOL DoChart(CallContextObj *pCallContextObj)
{
CDC oMemDC;
CBitmap *pOldBmp;
CBitmap oBmp;long lWidth = 300;
long lHeight = 200;
pCallContextObj->GetParameterValue("ChartWidth",&lWidth);
pCallContextObj->GetParameterValue("ChartHeight",&lHeight);CRect oBmpSize(0,0,lWidth,lHeight);
oMemDC.CreateCompatibleDC(NULL);
int iOldMapMode = oMemDC.SetMapMode(MM_TEXT);CWindowDC dcScreen(NULL);
oBmp.CreateCompatibleBitmap(&dcScreen,oBmpSize.Width(), oBmpSize.Height());
pOldBmp = oMemDC.SelectObject(&oBmp);
WORD wChartType = 88;
pCallContextObj->GetParameterValue("ChartType",&wChartType);BOOL bRetval = FALSE;
char caHeaders[512];
strcpy(caHeaders,"Invalid Chart Type");switch (wChartType)
{
case 0:
bRetval = DoLineChart(pCallContextObj,&oMemDC,caHeaders,oBmpSize);
break;case 1: bRetval = DoBarChart(FALSE,pCallContextObj,&oMemDC,caHeaders,oBmpSize); break; case 2: bRetval = DoBarChart(TRUE,pCallContextObj,&oMemDC,caHeaders,oBmpSize); break; case 3: bRetval = DoOpenHiLowCloseChart(pCallContextObj,&oMemDC,caHeaders,oBmpSize); break; case 4: bRetval = DoPieChart(pCallContextObj,&oMemDC,caHeaders,oBmpSize); break; }
if (bRetval)
{
LPSTR cpBuf = pCallContextObj->GetOutputBufferPtr();long lQuality = 75; pCallContextObj->GetParameterValue("ImageQuality",&lQuality); char caContentType\[256\]; long lDataSize = WriteImage(oBmp,cpBuf,pCallContextObj->GetOutputBufferSize(),caHeaders,(DWORD)lQuality); if (lDataSize > 0) { pCallContextObj->SuppressHeaders(); // pCallContextObj->GetMimeType("x.bmp",caContentType); pCallContextObj->GetMimeType("x.jpg",caContentType); sprintf(caHeaders,"Content-Type: %s%sContent-Length: %d%s%s",caContentType,cpCRLF,lDataSize,cpCRLF,cpCRLF); // write out our custom headers if (pCallContextObj->ServerSupportFunction(HSE\_REQ\_SEND\_RESPONSE\_HEADER,"200 OK",0,(LPDWORD)caHeaders) || ::GetLastError() == 10054) pCallContextObj->WriteClient((LPVOID)cpBuf,(LPDWORD)&lDataSize); \*cpBuf = 0; } else bRetval = FALSE; }
oMemDC.SetMapMode(iOldMapMode);
oMemDC.SelectObject(pOldBmp);oMemDC.DeleteDC();