[fpc-devel] Rect drawing inconsistency in TFPCanvas
Michael Van Canneyt
michael at freepascal.org
Sat Feb 9 19:43:51 CET 2019
On Thu, 7 Feb 2019, Ondrej Pokorny wrote:
> 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.
More information about the fpc-devel
mailing list