好的,所以我的双缓冲区工作正常,但似乎它使用了大量的内存。
我知道双缓冲区应该存储我正在绘制的椭圆的副本,而不是在屏幕上绘制它,但之后它会删除副本并制作新的副本,但它似乎不会删除它 这是我的代码
hdc=GetDC(hWnd);
HDC memDC=CreateCompatibleDC(hdc);
HBITMAP hMemMap=CreateCompatibleBitmap(hdc, 300, 300);
HBITMAP hOldMap=(HBITMAP)SelectObject(memDC, hMemMap);
// Drawing
Graphics draw(memDC);
draw.FillRectangle(&green, 0, 0, 300, 25);
Font font(&fontfamily, 14, 0, UnitPixel);
PointF p1(180.0f, 4.0f);
PointF p2(30.0f, 4.0f);
draw.DrawString(level, -1, &font, p2, &blue);
draw.DrawString(str, -1, &font, p1, &blue);
draw.FillEllipse(&red, ball1.Ex, ball1.Ey, 25, 25);
draw.FillEllipse(&red, ball2.Ex, ball2.Ey, 25, 25);
draw.FillEllipse(&red, ball3.Ex, ball3.Ey, 25, 25);
draw.FillEllipse(&red, ball4.Ex, ball4.Ey, 25, 25);
draw.FillEllipse(&red, ball5.Ex, ball5.Ey, 25, 25);
draw.FillEllipse(&red, ball6.Ex, ball6.Ey, 25, 25);
draw.FillEllipse(&red, ball7.Ex, ball7.Ey, 25, 25);
draw.FillEllipse(&red, ball8.Ex, ball8.Ey, 25, 25);
draw.FillEllipse(&red, ball9.Ex, ball9.Ey, 25, 25);
draw.FillEllipse(&red, ball10.Ex, ball10.Ey, 25, 25);
BitBlt(hdc, 0, 0, 300, 300, memDC, 0, 0, SRCCOPY);
SelectObject(memDC, hOldMap);
DeleteObject(hMemMap);
DeleteDC(memDC);
有什么想法吗?
答案 0 :(得分:1)