Quote:
|
Originally Posted by Aknod
Thanks you eXeption. The example is pretty good and usefull for me. Is it possible to reconstruct the LineAA function a little so that it could draw lines with defined strength?
I tried this (a part of LineAA):
Code:
Dim ix as integer
For loopc = start To finish
AlphaBlendPixel hdc, CInt(dx - 0.5), loopc, LR, LG, LB, 1 - FracPart(dx)
for ix = 1 to LineStrength
AlphaBlendPixel hdc, CInt(dx - 0.5) + ix, loopc, LR, LG, LB, FracPart(dx)
next ix
AlphaBlendPixel hdc, CInt(dx - 0.5) + ix + 1, loopc, LR, LG, LB, 1 - FracPart(dx)
dx = dx + dydx
Next loopc
where LineStrength is a new function parameter that defines how fat the line will be.
But it does not seem to work propper. Could you help me with that, please.
|
It wont work proper , because my implimentation of WU algorithm can't handle curves with arbitary width.
I have done it some time ago but i think it is not currently with me..
I'll give you some ideas and references...
Try coding usin Gupta-Sproull's 'generalised' algorithm.
Arbitary width curves are antialiased considering any line or curve of some thickness 'W', as two paralell 'single width' lines/curves with a seperation equal to 'W', and then scan converting the resulting vector object.
There is also an 'in-efficient' method of drawing arbitary width, is to prepare lookup tables which stores the boundary points to be blended.
Any way stick to the 'paralell curve method'.
The best and most generalised method is to stroke with a specified width brush (NB: here 'Brush' referes to any shaped bitmap representation, not the 'Brush' in windows GDI), and then applying filters upon it. It gives more control over the the antialiasing quality, the shape, color of your curves. You can even use custom bitmaps (images) to draw a curve.
The method of filtering can be implimented in VB as follows.
1) create a temp DC
2) Create a Brush. For this just create a memory DIB of higher resolution than actually needed. I have used resolutions upto 16 times and gives the best results. Choose the resolution according to the quality you require, i.e. higher the quality required, higher the resolution. In this case the dimensions of the DIB is (W*16 x W*16).
3) Solve the curve or line by assuming width is only '1', and store all the pixels to be drawn in an array. This curve is actually passing through the middle of the required curve/line of width 'W'. Remember this curve should also be solved in the resolution we chose in step 2.
4) Select an appropriate step value to paint. this step value is to step through the array of points we have, and to paint. The most suitable value seems to be W*0.25.
5)In a loop which goes from 0 to the number of points in the coordinate array, with a step value equal to W*.25.
6)In the loop simply Blit the DIB with the coordinates in the array centered.
7)Now blit the contents of our DC, to the destination DC by pixel averaging redusing the resolution to the target DC's resolution (in our case it is 1/16).
8)You have done it!
Some references I found are attatched with this post.
And some more easy to impliment but in-efficient methods do exist, like, If you want to antialias a curve of width 'W', simply draw antialiased lines of length 'W' normal to the curve all the way to the end.
Refer also "Computer Graphics - Principles and practice by James D. Foley".