BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Smooth diagonal Lines
Goto page 1, 2  Next
 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
John
Guest





PostPosted: Wed Sep 06, 2006 7:53 pm    Post subject: Smooth diagonal Lines Reply with quote



Hello,

I have to draw on B&W picture some diagonal lines.
Unfortunately using Moveto lineTo produce very sharp lines.
I cannot use Antialiasing since I use only 2 colors (Blaco or white).
Do someone has a code for making better line aspect ?
thanks

John
Back to top
Finn Tolderlund
Guest





PostPosted: Wed Sep 06, 2006 8:08 pm    Post subject: Re: Smooth diagonal Lines Reply with quote



"John" <nospam (AT) nospam (DOT) com> skrev i en meddelelse
news:44fee0e1 (AT) newsgroups (DOT) borland.com...
Quote:
I have to draw on B&W picture some diagonal lines.
Unfortunately using Moveto lineTo produce very sharp lines.

That is not possible to avoid when you are using only black and white.

Quote:
I cannot use Antialiasing since I use only 2 colors (Blaco or white).
Do someone has a code for making better line aspect ?

You could try to use the Bresenham line algorithm and see if that works
better for you.
You can find a Delphi implementation on my website
--
Finn Tolderlund
http://www.tolderlund.eu/delphi/
Back to top
Mike Williams (TeamB)
Guest





PostPosted: Wed Sep 06, 2006 9:04 pm    Post subject: Re: Smooth diagonal Lines Reply with quote



John wrote:

Quote:
I have to draw on B&W picture some diagonal lines.
Unfortunately using Moveto lineTo produce very sharp lines.
I cannot use Antialiasing since I use only 2 colors (Blaco or white).
Do someone has a code for making better line aspect ?

My suggestion would be to open a copy of the bitmap in mspaint or your
favorite drawing program and attempt to make a black and white line
look better there. I think you'll find that it will make no
difference. The pixels are either on or off. It may be that a wider
line will look less jagged than a narrow line but I don't know what
sizes you're dealing with.

The main advantage of the algorithm that Finn referenced is that it's
fast because it uses only integer arithmetic. However, I would think
that the low level GDI code would also be efficient and may very well
use the same algorithm but in hand coded assembly. Your post doesn't
make it sound like performance is the problem and that it's only
appearance that you're concerned about.

--
-Mike (TeamB)
Back to top
Nils Haeck
Guest





PostPosted: Wed Sep 06, 2006 9:16 pm    Post subject: Re: Smooth diagonal Lines Reply with quote

Search for "WU antialiased line". You'll have to do a lot of low-level
coding though. Also check out Graphics32, it can render polygons (a "smooth
line" is actually a rectangle at high precision).

FWIW, I have created a new library, called Pyro, that you can use to draw
any shapes (paths, beziers, lines, circles, roundrects, etc), with many
useful features:
- 256 levels of AA
- partial transparency on fill and stroke
- dashed strokes
- 3 different linecaps
- fillrules
and many more

You can check the library out here:
http://www.simdesign.nl/forum/viewtopic.php?t=648

It is not free; DCU version is Eur 99, Source version is Eur 449.

You can also use it to render SVG, a very powerful vector format. That
requires the SVG plugin.

Nils Haeck
www.simdesign.nl

"John" <nospam (AT) nospam (DOT) com> schreef in bericht
news:44fee0e1 (AT) newsgroups (DOT) borland.com...
Quote:
Hello,

I have to draw on B&W picture some diagonal lines.
Unfortunately using Moveto lineTo produce very sharp lines.
I cannot use Antialiasing since I use only 2 colors (Blaco or white).
Do someone has a code for making better line aspect ?
thanks

John
Back to top
Mike Williams (TeamB)
Guest





PostPosted: Wed Sep 06, 2006 10:42 pm    Post subject: Re: Smooth diagonal Lines Reply with quote

Nils Haeck wrote:

Quote:
Search for "WU antialiased line".

How well does it work in black and white (no shades of gray)?

Quote:
"John" <nospam (AT) nospam (DOT) com> schreef in bericht
I cannot use Antialiasing since I use only 2 colors (Blaco or
white).

--
-Mike (TeamB)
Back to top
Jens Gruschel
Guest





PostPosted: Wed Sep 06, 2006 11:08 pm    Post subject: Re: Smooth diagonal Lines Reply with quote

Quote:
How well does it work in black and white (no shades of gray)?

Might be interesting to draw the line with antialiasing and then convert
the result to b&w using dithering (I guess it looks worse than a simple
line).

--
Jens Gruschel
http://www.pegtop.net
Back to top
Mike Williams (TeamB)
Guest





PostPosted: Wed Sep 06, 2006 11:27 pm    Post subject: Re: Smooth diagonal Lines Reply with quote

Jens Gruschel wrote:

Quote:
Might be interesting to draw the line with antialiasing and then
convert the result to b&w using dithering (I guess it looks worse
than a simple line).

I wondered about dithering as well but without knowing the line width
it's hard to say if that could be helpful.

--
-Mike (TeamB)
Back to top
Nils Haeck
Guest





PostPosted: Wed Sep 06, 2006 11:32 pm    Post subject: Re: Smooth diagonal Lines Reply with quote

Quote:
How well does it work in black and white (no shades of gray)?

If you only have 2 colours (1bit pixel format) then by definition you cannot
anti-alias the colours.

The only thing you can then do is use a process called dithering, but that's
more for surfaces, not so much for very thin lines (analogous to how
newspaper photos show the dots if you look real close).

Nils
Back to top
Mr. X
Guest





PostPosted: Wed Sep 06, 2006 11:49 pm    Post subject: Re: Smooth diagonal Lines Reply with quote

For 2 color bitmaps (B/W), if you have diagonal lines at 45 degrees angles,
you will get sharp crisp lines.
Any other angle and you will need antialiasing.

Best
X

"John" <nospam (AT) nospam (DOT) com> wrote in message
news:44fee0e1 (AT) newsgroups (DOT) borland.com...
Quote:
Hello,

I have to draw on B&W picture some diagonal lines.
Unfortunately using Moveto lineTo produce very sharp lines.
I cannot use Antialiasing since I use only 2 colors (Blaco or white).
Do someone has a code for making better line aspect ?
thanks

John

Back to top
Mike Williams (TeamB)
Guest





PostPosted: Thu Sep 07, 2006 12:08 am    Post subject: Re: Smooth diagonal Lines Reply with quote

Nils Haeck wrote:

Quote:
If you only have 2 colours (1bit pixel format) then by definition you
cannot anti-alias the colours.

I knew that already, as did the original poster, which is why I asked.
I should have worded my response better.

--
-Mike (TeamB)
Back to top
Nils Haeck
Guest





PostPosted: Thu Sep 07, 2006 1:00 am    Post subject: Re: Smooth diagonal Lines Reply with quote

Yes.. and I didn't read correctly Smile I didn't notice he actually meant to
only use two colours.

Nils
Back to top
Lord Crc
Guest





PostPosted: Thu Sep 07, 2006 1:16 am    Post subject: Re: Smooth diagonal Lines Reply with quote

On Wed, 6 Sep 2006 16:53:25 +0200, "John" <nospam (AT) nospam (DOT) com> wrote:

Quote:
Do someone has a code for making better line aspect ?

I have some code which can change the resolution of the monitor, which
is about the only thing you can do to make it look better...

- Asbjørn
Back to top
Jens Gruschel
Guest





PostPosted: Thu Sep 07, 2006 1:27 am    Post subject: Re: Smooth diagonal Lines Reply with quote

Quote:
I wondered about dithering as well but without knowing the line width
it's hard to say if that could be helpful.

Another idea is what TFTs often do: dithering in time. If you refresh
the line very often you can simulate gray values and therefore
antialiasing. However this might not be the solution the OP wants to hear.

--
Jens Gruschel
http://www.pegtop.net
Back to top
Rudy Velthuis [TeamB]
Guest





PostPosted: Thu Sep 07, 2006 2:29 am    Post subject: Re: Smooth diagonal Lines Reply with quote

At 17:08:28, 06.09.2006, Finn Tolderlund wrote:

Quote:
You could try to use the Bresenham line algorithm

What do you think MoveTo/LineTo use?

--
Rudy Velthuis [TeamB] http://rvelthuis.de/

"Our children are not born to hate, they are raised to hate."
-- Thomas della Peruta
Back to top
Rudy Velthuis [TeamB]
Guest





PostPosted: Thu Sep 07, 2006 2:39 am    Post subject: Re: Smooth diagonal Lines Reply with quote

At 20:08:41, 06.09.2006, Jens Gruschel wrote:

Quote:
How well does it work in black and white (no shades of gray)?

Might be interesting to draw the line with antialiasing and then
convert the result to b&w using dithering (I guess it looks worse than
a simple line).

But usually, AA on lines only uses one or two pixels (except for almost
vertical or horizontal lines), and dithering would not make it look any
better, I'd guess. It even might make the line look worse, even more
ragged.

--
Rudy Velthuis [TeamB] http://rvelthuis.de/

"The fear of death is the most unjustified of all fears, for
there's no risk of accident for someone who's dead."
-- Albert Einstein.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.