I am writing program in c++ gdi gdi+. Drawing large image on gdi+ bitmap is slow is using gdi+ api. So I used the following way to draw:
Bitmap img(xxx);
Graphics gr(&img);
HDC dc = gr.GetHDC();
::StretchDIBits(
dc,
rec.left, rec.top,
(rec.right - rec.left), (rec.bottom - rec.top),
m_recRegin.left , m_recRegin.top,
m_recRegin.right - m_recRegin.left, m_recRegin.bottom - m_recRegin.top,
XXX, XXX, DIB_RGB_COLORS, SRCCOPY);
gr.ReleaseHDC(dc);
this code run perfectly some time. But when the system-wide pool is full by creating lots of compatibleDCs with large size of CBitmap. It seems can not draw any thing on the Bitmap.
What happened? when this part of code failed, I can still draw on the graphics using GDI+ APIs
GetLastError() return 8.
Many thanks!