### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Author Topic: Bgrabitmap draw psDot/psDash line without antialiassing  (Read 221 times)

#### MaartenJB

• Jr. Member
• Posts: 72
##### Bgrabitmap draw psDot/psDash line without antialiassing
« on: April 01, 2020, 01:50:40 pm »
Hi,

I've noticed that when I want to draw a dash line in bgrabitmap that I need to use the antialias function.

Code: Pascal  [Select][+][-]
1. Bitmap.PenStyle := psDash;
2.
3. // Gives me a nice dash line, but is a lot slower than below
4. Bitmap.DrawPolyLineAntialias([Point(0,50), Point(Bitmap.Width,50)], BGRA(0,255,0), 1,3,True,65535);
5.
6. // Is fast, but only gives me a solid line
7. Bitmap.DrawPolyLine([Point(0,55), Point(Bitmap.Width,55)],  BGRA(255,255,0), False, dmSet);
8. Bitmap.DrawLine(0,60, Bitmap.Width,60, BGRA(0,255,0), False, dmSet);
9.

I only need to draw simple straight horizontal and vertical dash lines, the AA version is more than 100 times slower, so would like to use a procedure without. Is that possible?

Best regards,

Maarten

#### circular

• Hero Member
• Posts: 3308
##### Re: Bgrabitmap draw psDot/psDash line without antialiassing
« Reply #1 on: April 01, 2020, 11:32:59 pm »
Hmmm, I suppose the antialias version can be optimized. The aliased version here is not necessary because the lines are horizontal and vertical.

For this, you could easily write your own procedure. Basically you can achieve what you want by calling HorizLine and VertLine functions with alternating colors.

Tell me if you come up with something, maybe I can add it to next version of BGRABitmap.
Conscience is the debugger of the mind