当前位置: 代码迷 >> VC/MFC >> GDI+抗锯齿功能在双缓冲时无效解决思路
  详细解决方案

GDI+抗锯齿功能在双缓冲时无效解决思路

热度:707   发布时间:2016-05-02 03:34:40.0
GDI+抗锯齿功能在双缓冲时无效
正常使用GDI+抗锯齿(直接在DC上画图)时有抗锯齿效果;
效果图:

OnPaint()中关键代码如下:

CPaintDC dc(this);
Graphics graphics(dc.m_hDC);
graphics.SetSmoothingMode(SmoothingModeHighQuality);//抗锯齿 
Pen black  (Color(255, 0, 0, 0));
graphics.DrawEllipse(&black, 30, 30, 50, 50);

使用双缓冲时,就没有抗锯齿效果了;
效果图:

OnPaint()中关键代码如下:

CPaintDC dc(this);
CDC dcBmp;
CBitmap memBitmap;
CRect rect;
GetClientRect(&rect);
dcBmp.CreateCompatibleDC(&dc);
memBitmap.CreateCompatibleBitmap(&dcBmp, rect.Width(), rect.Height());
dcBmp.SelectObject(&memBitmap);
dcBmp.FillSolidRect(0, 0, rect.Width(),rect.Height(), RGB(0xFF,0xFF,0xFF));

Graphics graphics(dcBmp.m_hDC);
graphics.SetSmoothingMode(SmoothingModeHighQuality);//抗锯齿 

Pen black(Color(255, 0, 0, 0));
graphics.DrawEllipse(&black, 30, 30, 50, 50);
dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcBmp,0,0,rect.Width(),rect.Height(),SRCCOPY);
dcBmp.DeleteDC();
memBitmap.DeleteObject();

我是想在双缓冲时使用GDI+抗锯齿效果,还请各位帮忙看下问题出在哪?
------解决思路----------------------
帮结帖+蹭分
  相关解决方案