void Bresenham_line(CDC *pDC, int x0, int y0, int x1, int y1, long color) { int dx = abs(x1 - x0); int dy = abs(y1 - y0); int x = x0; int y = y0; int stepX = 1; int stepY = 1; if( ) //从右画 stepX = -1; if( ) stepY = -1; if( ) //沿着最长的那个轴前进 { int e = ( ); for(int i=0; i<=dx; i++) { pDC->SetPixel(x, y, color); x += ( ); e += ( ); if(e >= 0) { y += stepY; e -= dx; } } } else { int e = 2 * dx - dy; for(int i=0; i<=dy; i++) { pDC->SetPixel(x, y, color); y += ( ); e += ( ); if( ) { x += stepX; e -= ( ); } } } }