Bresenham Line Drawing Algorithm
Disclaimer: I know nothing of C++, but I'll help you as much as I can.




Overall, your code looks good. A+ for readability! Probably a missing spot somewhere, but no biggy. Still, your code is easy to read and follow.



On your BresLine(), you have this:

int dy = y2 - y1;
int dx = x2 - x1;
double m = (double)dy/(double)dx;
[...]
int limit = ((abs(dx)&gt;abs(dy))?abs(dx):abs(dy))/2;


You could try to store that abs() somewhere, to shave on re-calling it.



You have the functions NextDiIfDiIsGreaterThanOrEqualtoZero() and NextDiIfDiIsSmallerThanZero(). They have giant names. And the code is almost the same. I suggest the following:

int NextDi(double m, int di, int x1, int y1, int x2, int y2)
{
    int di_plus_1 = -1;
    int dx = x2 - x1;
    int dy = y2 - y1;

    int octet = Octet(m, x1, y1, x2, y2);

    switch(octet)
    {
        case 1:
        case 5:
            di_plus_1 = di - 2 * (di &gt; 0 ? dx - dy : dy); 
            break;
        case 2:
        case 6:
            di_plus_1 = di + 2 * (di &gt; 0 ? dx - dy : dx); 
            break;
        case 3:
        case 7:
            di_plus_1 = di - 2 * (di &gt; 0 ? dx - dy : dx); 
            break;
        case 4:
        case 8:
            di_plus_1 = di + 2 * (di &gt; 0 ? dx - dy : dy); 
            break;
    }



    return di_plus_1;
}


It isn't the prettiest thing on Earth, but may work for you. To call it, you don't have to change anything! Just remove that if on BresLine. With some bitwise operations, you can cut down this code by a lot!



If you see something innacurate, please tell me. I haven't touched on the remaining functions, but I'm specially worried about the Octet function.