使用VC 6.0 mfc实现编程
刚学的图像学,挺难学的,show 代码吧
void CLineView::OnDraw(CDC* pDC) {
CLineDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
int x1 ,x2 ,y1,y2 ;
x1 = 0 ; y1 = 0 ; x2 = 1000 ; y2 = 500 ;
COLORREF c = RGB(255,0,0);
double k = y2 - y1/ x2-x1 ;
double yT = y1 ;
double d ;
double dTemp = 0.5 - k ;
for(int x = x1;x<=x2;x++) {
d = dTemp + 1 - k ; if(d < 0 )
{ dTemp = d ;
yT ++ ;
} else { dTemp = dTemp - k ; }
pDC->SetPixel(x,yT,c); }
}
用中点Bresenham画直线算法绘制任意斜率直线,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/gubou/p/3759565.html