Solved

Fastest Bresenham algorithm

Posted on 2002-03-13
4
1,155 Views
Last Modified: 2008-02-01
Hi Experts,

I've read one in a book, there is the most fastest line algorithm founded by two university guys, I don't remember the name but their algorithm is based on improved Bresenham.

So please can someone create a line function which I can simply use based on that fastest improved Bresenham ?

for example a function like this :

function Line(x1, y1, x2, y2: integer)

So I can simply use that on my program thanks alot experts... you are all always great on helping student like me :)
0
Comment
Question by:comicboy
  • 2
4 Comments
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6860615
I searched on Google with "improved Bresenham2 and found this http://www.cs.unc.edu/~davemc/Class/136/Lecture9/Lines.html
The source is in C, but conversion should be easy.
0
 

Accepted Solution

by:
Rabster earned 50 total points
ID: 6860994
A guy called G. Hoffman has adapted a routine from C based on an algorithm from a Kenny Hoff. This is an improved version of Bresenham's algorithm:

Procedure MakeBLine(p0,q0,p1,q1, pal,col : Byte);
var
  x,y,dx,dy,
  adx,ady,
  ix,iy,du,
  dr,pp,cp,
  i : Integer;
Begin
  dx := p1-p0;
  dy := q1-q0;
  adx := Abs(dx);
  ady := Abs(dy);
  x := p0;
  y := q0;
  cp := 0;
  If dx > 0 then
  ix:= 1
  else
  begin
    ix := -1;
    cp := -1;
  end;
  if dy > 0 then
  iy := 1
  else
  iy := -1;
  If adx >= ady then
  begin
    dr := 2 * ady;
    du := dr-2*adx;
    pp := dr-adx;
    For i := 0 to adx do
    begin
      {SpcSixel(x,y,pal,col);  }
      x:= x + ix;
      If pp > cp then
      begin
        y := y + iy;
        pp := pp + du;
      end
      else
      pp := pp + dr;
    end;
  end
  else
  begin
    dr := 2*adx;
    du := dr -2* ady;
    pp := dr-ady;
    For i := 0 to ady do
    begin
      {SpcSixel(x,y,pal,col); }
      y := y + iy;
      If pp > cp then
      begin
        x := x + ix;
        pp := pp + du;
      end
      else
      pp := pp + dr;
    end;
  end;
end;
0
 

Author Comment

by:comicboy
ID: 6864104
Well thanks, Robert and Rabster, now my turn to try your code...
0
 

Author Comment

by:comicboy
ID: 6920718
Sorry for long delay, my Delphi disc broken but now it's up again, I've tried your code...

Excellent!!! it's working as best and as fast as I need

Thanks :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi 2010 Export to pdf 2 288
Delphi selector screen 2 70
Dev Express grid collapse 2 39
How to define IfThen functions in one common unit? 4 45
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now