views:

245

answers:

0

Why can't the following code draw the content of graphics onto finalDC? It just draw black rectangle;

Bitmap* bitmapCanvasCore = new Bitmap(width, height ,PixelFormat24bppRGB);
xxxxxx // operation on bitmapCanvasCore...
Graphics * canvasGraphics = new Graphics(bitmapCanvasCore);
HDC tempdc = m_UnSelectedGraphics->GetHDC();
::SetStretchBltMode(dc, HALFTONE);
::StretchBlt(finalDC,  (int)(point.X) + m_pOffset.x, (int)(point.Y) + m_pOffset.y, 
     width * 0.5, width * 0.5, tempdc, 0 , 0, m_Root->GetWidth(), 

m_Root->GetHeight(), SRCCOPY);
m_UnSelectedGraphics->ReleaseHDC(tempdc);

I found if I make use of

Graphics gr(finalDC);
gr.DrawImage(bitmapCanvasCore,xxxx);

It is really slow on large image. So I want to use StretchBlt to accelerate it... but failed...