GDI+绘制图像出错

jinling4388 2019-03-12 04:12:53


static CSize m_szDot;
static COLORREF m_colorfill;
static COLORREF m_colorcir;


DrawDot(CDC* pDC,CPoint ptCenter,int nIndex)
{
Graphics graphics(pDC->m_hDC);
graphics.SetSmoothingMode(SmoothingModeHighQuality);
Pen pen(Color(GetRValue(m_colorcir), GetGValue(m_colorcir), GetBValue(m_colorcir)), 1);
graphics.DrawEllipse(&pen, ptCenter.x, ptCenter.y, m_szDot.cx, m_szDot.cy);
SolidBrush solidbrush(Color(GetRValue(m_colorfill)+5*nIndex, GetGValue(m_colorfill)+9*nIndex, GetBValue(m_colorfill)+10*nIndex));
graphics.FillEllipse(&solidbrush, ptCenter.x , ptCenter.y, m_szDot.cx, m_szDot.cy);
}


界面上没有绘制出来的圆圈。
...全文
157 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
schlafenhamster 2019-03-13
  • 打赏
  • 举报
回复
看我的图 ,园环 宽 10 ! 不是 5 !
jinling4388 2019-03-13
  • 打赏
  • 举报
回复
引用 4 楼 schlafenhamster 的回复:
注意 pen 宽 为 10 时 ,你的 代码 (是先画圆 后画背景)圆 只有 5 宽 。
m_szDot.cx = m_szDot.cy = 20;
圆的半径是20
schlafenhamster 2019-03-13
  • 打赏
  • 举报
回复
注意 pen 宽 为 10 时 ,你的 代码 (是先画圆 后画背景)圆 只有 5 宽 。
jinling4388 2019-03-13
  • 打赏
  • 举报
回复
引用 2 楼 zgl7903 的回复:
1: GDI+ 是否有初始化? 2: 绘制函数在哪里被调用的? 3: 各个参数 颜色 是否正常?
初始化过了,在OnPaint函数调用的,颜色是正常的 现在的问题是同样的代码在不同的工程中有的正常,有的没显示。2个工程都初始化过了,其余的调用和颜色配置完全一致。
zgl7903 2019-03-12
  • 打赏
  • 举报
回复
1: GDI+ 是否有初始化?
2: 绘制函数在哪里被调用的?
3: 各个参数 颜色 是否正常?


schlafenhamster 2019-03-12
  • 打赏
  • 举报
回复
void CMyImageDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
CPoint Center(200,200);
DrawDot(&dc,Center,0);
}
//
static CSize m_szDot(200,100);
static COLORREF m_colorfill=RGB(255,0,0);
static COLORREF m_colorcir=RGB(0,255,0);


void CMyImageDlg::DrawDot(CDC* pDC,CPoint ptCenter,int nIndex)
{
Graphics graphics(pDC->m_hDC);
graphics.SetSmoothingMode(SmoothingModeHighQuality);
SolidBrush solidbrush(Color(GetRValue(m_colorfill)+5*nIndex, GetGValue(m_colorfill)+9*nIndex, GetBValue(m_colorfill)+10*nIndex));
graphics.FillEllipse(&solidbrush, ptCenter.x , ptCenter.y, m_szDot.cx, m_szDot.cy);
Pen pen(Color(GetRValue(m_colorcir), GetGValue(m_colorcir), GetBValue(m_colorcir)), 10);
graphics.DrawEllipse(&pen, ptCenter.x, ptCenter.y, m_szDot.cx, m_szDot.cy);
}

15,978

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧