Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2019-02

Rect drawing inconsistency in TFPCanvas

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ondrej Pokorny

Hello,

when working with TFPCanvas, I face an annoying inconsistency between fcl-image and all other image libraries I know (including LCL Graphics).

The problem is that TFPCustomCanvas.FillRect and all other rect-aware methods (FillEllipse, etc...) fill 1 more pixel to the right and bottom.

E.g.

       MyCanvas.FillRect(0, 0, 50, 50);

- FP canvas draws a rectangle with 51x51 pixels.

- LCL Graphics draws a rectangle with 50x50 pixels. (And all other libraries like Delphi Graphics, BGRABitmap etc. do the same.)

---

IMO TFPCanvas is wrong because

1.) The rectangle should be filled up until the right/bottom coordinate
- that means excluding the pixel at (50, 50). And not including it.

2.) Rect(0, 0, 50, 50) has a width/height of 50 pixels - see "function TRect.getWidth" in FPC sources. In FPCanvas if you draw Rect(0, 0, 50,
50) it is 51x51 pixels, which is inconsistent.

3.) In FPCanvas if you draw Rect(0, 0, 50, 50) and Rect(50, 0, 100, 50) there is a 1px overlay between them! (That is wrong - Seen e.g. with dmAlphaBlend painting as in https://bugs.freepascal.org/view.php?id=34266 ).

4.) In FPCanvas if you draw Rect(0, 0, 0, 0) you get a 1px dot. (That is wrong.)

---

See the attached example project.

Should I report it in Mantis?

Ondrej

Reply by email

Michael Van Canneyt
to Ondrej Pokorny
Ondrej Pokorny wrote 40 lines
Hello, when working with TFPCanvas, I face an annoying inconsistency between fcl-image and all other image libraries I know (including LCL Graphics). The problem is that TFPCustomCanvas.FillRect and all other rect-aware methods (FillEllipse, etc...) fill 1 more pixel to the right and bottom. E.g.       MyCanvas.FillRect(0, 0, 50, 50); - FP canvas draws a rectangle with 51x51 pixels. - LCL Graphics draws a rectangle with 50x50 pixels. (And all other libraries like Delphi Graphics, BGRABitmap etc. do the same.) --- IMO TFPCanvas is wrong because 1.) The rectangle should be filled up until the right/bottom coordinate - that means excluding the pixel at (50, 50). And not including it. 2.) Rect(0, 0, 50, 50) has a width/height of 50 pixels - see "function TRect.getWidth" in FPC sources. In FPCanvas if you draw Rect(0, 0, 50, 50) it is 51x51 pixels, which is inconsistent. 3.) In FPCanvas if you draw Rect(0, 0, 50, 50) and Rect(50, 0, 100, 50) there is a 1px overlay between them! (That is wrong - Seen e.g. with dmAlphaBlend painting as in https://bugs.freepascal.org/view.php?id=34266 ). 4.) In FPCanvas if you draw Rect(0, 0, 0, 0) you get a 1px dot. (That is wrong.) --- See the attached example project. Should I report it in Mantis?

Yes, please.

Michael.

Reply by email