你有学习其他东西的功夫,就足够把GDI学好了,
VC下绘图使用GDI
给你个例子,创建一个单文档程序,在View类得OnDraw函数的尾部添加下面的代码,然后编译执行
CPen penRed(PS_SOLID,3,RGB(255,0,0));
CPen* pOldPen=NULL;
pOldPen=pDC->SelectObject(&penRed);
CRect rcClient;
GetClientRect(&rcClient);
CBrush brBlue(RGB(0,0,255));
CBrush* pOldBrush=NULL;
pOldBrush=pDC->SelectObject(&brBlue);
for(int w=0;w<2;w++)
{
const int nPoints=5;
double nAngle=(720.0/57.295)/(double)nPoints;
int xOffset=(w?1:-1)*rcClient.Width()/3;
pDC->SetPolyFillMode(w?ALTERNATE:WINDING);
CPoint ptPolyAr[nPoints];
for(int i=0;i
ptPolyAr[i].x=xOffset+(long)(sin((double)i*nAngle)*100.0);
ptPolyAr[i].y=(long)(cos((double)i*nAngle)*100.0);
ptPolyAr[i]+=rcClient.CenterPoint();
}
pDC->Polygon(ptPolyAr,nPoints);
}
pDC->SelectObject(pOldBrush);
pDC->SelectObject(pOldPen);
你有学习其他东西的功夫,就足够把GDI学好了,
VC下绘图使用GDI
给你个例子,创建一个单文档程序,在View类得OnDraw函数的尾部添加下面的代码,然后编译执行
CPen
penRed(PS_SOLID,3,RGB(255,0,0));
CPen*
pOldPen=NULL;
pOldPen=pDC->SelectObject(&penRed);
CRect
rcClient;
GetClientRect(&rcClient);
CBrush
brBlue(RGB(0,0,255));
CBrush*
pOldBrush=NULL;
pOldBrush=pDC->SelectObject(&brBlue);
for(int
w=0;w<2;w++)
{
const
int
nPoints=5;
double
nAngle=(720.0/57.295)/(double)nPoints;
int
xOffset=(w?1:-1)*rcClient.Width()/3;
pDC->SetPolyFillMode(w?ALTERNATE:WINDING);
CPoint
ptPolyAr[nPoints];
for(int
i=0;i
ptPolyAr[i].x=xOffset+(long)(sin((double)i*nAngle)*100.0);
ptPolyAr[i].y=(long)(cos((double)i*nAngle)*100.0);
ptPolyAr[i]+=rcClient.CenterPoint();
}
pDC->Polygon(ptPolyAr,nPoints);
}
pDC->SelectObject(pOldBrush);
pDC->SelectObject(pOldPen);
opencv,去opencv中文站看看吧