draw a line between two point & the line color will be black.

public Bitmap line(int x, int y, int x1, int y1,Bitmap b)
{
int i, j;
double m,t1,t2,t3,t4,bbb;

if (x > x1)
{
i = x;
x = x1;
x1 = i;
i = y;
y = y1;
y1 = i;
}

t1 = x;
t2 = y;
t3 = x1;
t4 = y1;
m=(t4-t2)/(t3-t1);
bbb = t2 – m * t1;
b.SetPixel(x,y,Color.Black);

for (i = x; i <= x1; i++)
{
t1 = m *Convert.ToDouble(i) + bbb;
j =Convert.ToInt16(t1);
b.SetPixel(i,j,Color.Black);
}

return b;
}

Advertisements