🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.graphics
18 messages
18 total messages Started by David HAROUCHE Thu, 17 Jul 2008 01:55
LineTo vs ScanLine
#351
Author: David HAROUCHE
Date: Thu, 17 Jul 2008 01:55
3 lines
880 bytes
What will be the most efficient ?

DH 
Re: LineTo vs ScanLine
#350
Author: Paul Nicholls
Date: Thu, 17 Jul 2008 02:03
11 lines
1074 bytes
"David HAROUCHE" <metanil@hotmail.com> wrote in message 
news:487ea677$1@newsgroups.borland.com...
> What will be the most efficient ?
>
> DH
>

do a test and find out

cheers,
Paul 
Re: LineTo vs ScanLine
#352
Author: David HAROUCHE
Date: Thu, 17 Jul 2008 02:50
3 lines
894 bytes
ScanLine...

DH 
Re: LineTo vs ScanLine
#363
Author: David HAROUCHE
Date: Thu, 17 Jul 2008 18:40
12 lines
1432 bytes
I found that drawing a line using ScanLine and a geometrical algorythm ( y= 
ax + b) goes faster than using LineTo...

>> think scanline will be that efficient drawing a line on a printer's 
>> canvas.
I don't know about the printer...What I plane to use about it is CopyRect 
from TBitmap to TPrinter....(eventually producing a WMF file)...

>> If you expect assistence, you need to learn how to ask better questions.
better ?

DH 
Re: LineTo vs ScanLine
#358
Author: GrandmasterB
Date: Thu, 17 Jul 2008 19:17
7 lines
1182 bytes
"David HAROUCHE" <metanil@hotmail.com> wrote in
> What will be the most efficient ?

Efficient at *what*?  They are two completely different things.  I dont 
think scanline will be that efficient drawing a line on a printer's canvas.

If you expect assistence, you need to learn how to ask better questions.
Re: LineTo vs ScanLine
#374
Author: David HAROUCHE
Date: Fri, 18 Jul 2008 23:49
4 lines
1102 bytes
I just calculate each y from two given points using y=ax +b and light a 
pixel using scanline... So I keep the "control" until the end... !

DH 
Re: LineTo vs ScanLine
#372
Author: Sasa Zeman
Date: Sat, 19 Jul 2008 00:09
12 lines
1368 bytes
David HAROUCHE wrote:

> I found that drawing a line using ScanLine and a geometrical algorythm (
> y= ax + b) goes faster than using LineTo...

In addition to other replies, please notice that there is many algorithms to
draw a line, depending on drawing speed and quality. There is also many
serious discussions and articles about this "simple" theme...

In this particular case, significant part of speed dependeds on chosen
algorithm as well, by side of the method LineTo actualy use to draw a pixel
on specific destionation (assuming thus is word about TBitmap).
Re: LineTo vs ScanLine
#378
Author: Sasa Zeman
Date: Sat, 19 Jul 2008 14:35
19 lines
2049 bytes
David HAROUCHE wrote:

> I just calculate each y from two given points using y=ax +b and light a
> pixel using scanline... So I keep the "control" until the end... !

This is perhaps quality, but hardly the fastest way. Main difference between
mathematical and computer line is infinite number of dots in mathematical
definition of a line and finite number of squares (pixels) in comuter
graphics. That mean we need to make aproximation algorithm which will turn 
on the squares which ideal line cross. Thus we have a line composed of N
horizontal and M vertical lines depending on angle and the problem stays to
determinate how many of them will be necessary.

In case of using explicit formula to calculate each y, assume x
multiplifications and adding, which is hardly optimal. We will have many 
round(a*x) values equal (depending on angle). In case of optimiztion we
need to determinate how many (and how long) horiyontal and vertical line we
will draw, which assume N adding only. One of the first results on this
approximation is Bresenam's algorithm.
Re: LineTo vs ScanLine
#379
Author: Sasa Zeman
Date: Sat, 19 Jul 2008 14:37
19 lines
2029 bytes
David HAROUCHE wrote:

> I just calculate each y from two given points using y=ax +b and light a
> pixel using scanline... So I keep the "control" until the end... !

This is perhaps quality, but hardly the fastest way. Main difference between
mathematical and computer line is infinite number of dots in mathematical
definition of a line and finite number of squares (pixels) in comuter
graphics. That mean we need to make aproximation algorithm which will turn 
on the squares which ideal line cross. Thus we have a line composed of N
horizontal and M vertical lines depending on angle and the problem stays to
determinate how many of them will be necessary.

In case of using explicit formula to calculate each y, assume x
multiplifications and adding, which is hardly optimal. We will have many 
round(a*x) values equal (depending on angle). In case of optimiztion we
need to determinate how many (and how long) horiyontal and vertical line we
will draw, which assume N adding only. One of the first results on this
approximation is Bresenham's algorithm.
Re: LineTo vs ScanLine
#381
Author: David HAROUCHE
Date: Sat, 19 Jul 2008 17:11
6 lines
1118 bytes
Yes,

and you can't imagine how faster it runs when you correctly bufferize the 
drawings...

DH 
Re: LineTo vs ScanLine
#383
Author: David HAROUCHE
Date: Sat, 19 Jul 2008 23:29
8 lines
1406 bytes
I found that with Delphi, when you can light up all pixels using ScanLine 
(regardless 3D/2D scales and ranges checks),
you can use geometrical approach for drawing, quicker (in terme of drawing 
speed) than using GDI/VCL functions...

The speed can be increased from dramatical to OpenGL's concurrency...

DH 
Re: LineTo vs ScanLine
#382
Author: Sasa Zeman
Date: Sun, 20 Jul 2008 01:00
10 lines
1431 bytes
David HAROUCHE wrote:

> and you can't imagine how faster it runs when you correctly bufferize the
> drawings...

Well, I made quite large ammount of low level coding regarding computer
graphic (Image Processing task related) and Delphi in the past... Some of
the basics stuff can be found at Booland newsgroups arhive at
www.tamaracka.com (search for "Sasa scanline"). It may be interesting to
look.
Re: LineTo vs ScanLine
#384
Author: Peter Below (TeamB)
Date: Sun, 20 Jul 2008 08:46
14 lines
1435 bytes
Sasa Zeman wrote:

> One of the first results on this
> approximation is Bresenham's algorithm.

Windows has a build-in version of that, by the way: the LineDDA API
function.

-- 
Peter Below (TeamB)  
Don't be a vampire (http://slash7.com/pages/vampires), 
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
Re: LineTo vs ScanLine
#136
Author: David HAROUCHE
Date: Sun, 20 Jul 2008 11:51
5 lines
1225 bytes
>> Windows has a build-in version of that, by the way: the LineDDA API
>> function.
Yes, but I need to have control for every pixel I do light up !

DH 
Re: LineTo vs ScanLine
#137
Author: Anders Isaksson
Date: Sun, 20 Jul 2008 13:41
13 lines
1607 bytes
David HAROUCHE wrote:
>>> Windows has a build-in version of that, by the way: the LineDDA API
>>> function.
> Yes, but I need to have control for every pixel I do light up !

You do have that control with the LineDDA, as it calls back to you for each 
pixel to draw. Unfortunately, this makes it rather slow, comapared to 
scanline drawing.

-- 
Anders Isaksson, Sweden
BlockCAD:  http://web.telia.com/~u16122508/proglego.htm
Gallery:   http://web.telia.com/~u16122508/gallery/index.htm
Re: LineTo vs ScanLine
#138
Author: David HAROUCHE
Date: Sun, 20 Jul 2008 14:57
6 lines
1469 bytes
>> You do have that control with the LineDDA, as it calls back to you for 
>> each pixel to draw. Unfortunately, this makes it rather slow, comapared 
>> to scanline drawing.
...and quick drawings...

DH 
Re: LineTo vs ScanLine
#143
Author: Nils Haeck
Date: Wed, 23 Jul 2008 18:05
14 lines
1431 bytes
Look up the Bresenham line agorithm.

If you want quality lines, just lighting up single pixels as on/off is 
*bad*. You have to work with semi-transparency.

Nils

"David HAROUCHE" <metanil@hotmail.com> schreef in bericht 
news:48812c28@newsgroups.borland.com...
>I just calculate each y from two given points using y=ax +b and light a 
>pixel using scanline... So I keep the "control" until the end... !
>
> DH
> 
Re: LineTo vs ScanLine
#178
Author: David HAROUCHE
Date: Fri, 25 Jul 2008 20:30
44 lines
2321 bytes
I use a vector approach of the drawings, and a RGBTriple access for 
lightning up any pixel...My first object for that one I wrote, named TLight.

Works like that :

with TLight.Create(mybitmap, x, y)
    do begin
                Transparency := 50;   // set its transparency (according to 
the "under/actual" pixel)
                Color := clBlue;        // set its color

               Commit;            // That applys the changes (with VCL, a 
ScanLine operation will be done on mybitmap)

              Free;
      end;

for drawing a line, I do use something like :

l:=TLine(A,B); // that creates an y=ax+b object from two given points...

with TLight.Create(MyBitmap)
    do begin
                i:= A.x

               while i <= B.x
                    do begin
                                 x := i:
                                y := l.a * x + l.b;
                                color := mycolor;

                              Commit;

                             i := i + 1; // here  I can play to draw dotted 
or not lines
                        end;

               free;
        end;

That goes nearly faster than Canvas.LineTo ! And its very usefull for 3D 
translation...

DH 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads