Hi,

I recently learned how to render anti-alias lines using the Wu algorithm. All was going well until I decided to change the background color from black to another color, and the results changed to this:

from this:

To solve the problem I tried to alpha blend the resulting pixel, calculated with the Wu algorithm, with the background pixel underneath it. The results did not look any better. So, is there any way to modify the Wu algorithm to take in account the background pixel when calculating the levels of intensity for the new pixel of the anti-alias line? This article( http://www.codeproject.com/Articles/13360/Antialiasing-Wu-Algorithm ) does it successfully but I can't duplicate the results because I have trouble deciphering the source code. Also are there any smoothing techniques that I could use to smooth out the lines? Because if you look at the lines of the black image you will notice a candy cane like effect on some of the lines.

Here is some source code to help under stand what's going on:

if( fabs(delta.x) >= fabs(delta.y) ) // line is more horizontal { if( p0.x > p1.x ) // process left to right { SmyVectorF temp = p0; p0 = p1; p1 = temp; delta = SmyVectorF( p1.x-p0.x, p1.y-p0.y ); } int x0 = (int)floor(p0.x); // start x int x1 = (int)floor(p1.x); // end x float y = p0.y; float gradient = delta.y / delta.x; // slope of the line for( int x = x0; x < x1; x++ ) { if( x >= 0 && x < w && y >= 0 && y <= h ) { float intensity1 = y-float(floor(y)); float intensity0 = 1.f-intensity1; UNINT pixel = (UNINT) (floor(y)*w)+x; backbuffer->bits[pixel] = SMYUTI_rgb( UNCHR(red*intensity0), UNCHR(green*intensity0), UNCHR(blue*intensity0) ); backbuffer->bits[(pixel+=w)] = SMYUTI_rgb( UNCHR(red*intensity1), UNCHR(green*intensity1), UNCHR(blue*intensity1) ); } y += gradient; } if( p0.y >= 0 && p0.x >= 0 && p0.y <= h && p0.x <= w ) backbuffer->bits[int(p0.y)*w+int(p0.x)] = m_color; // render start pixel if( p1.y >= 0 && p1.x >= 0 && p1.y <= h && p1.x <= w ) backbuffer->bits[int(p1.y)*w+int(p1.x)] = m_color; // render end pixel }

Thanks in advance.