I wonder about always calling the inherited Paint, in case something in the base control is done. But that's probably unnecessary.Yes, sometimes "hidden" things happen in the overwritten Component / procedure .. :o
Your way is correct. As Circular mentioned, using CanvasBGRA seems a good idea, or even Canvas2d.I've never used BGRA, just discovered it today.
One other note is that if you are trying to be more efficient or using this way for big controls, you can create and destroy the Bitmap with controls Create and destroy, and fill it with transparent pixels every time. This way is more efficient as you do not make and allocate memory for each refresh of the control.Yes, I also thought "why is the bitmap always created and destroyed ?"
What does Canvas2D do different to CanvasBGRA ?
What is "transparent pixels" in BGRA ?
Hi
Have a look at
https://wiki.lazarus.freepascal.org/BGRABitmap_tutorial_14 (https://wiki.lazarus.freepascal.org/BGRABitmap_tutorial_14)
The text, drawn by Canvas.TextOut() , looks better than the one drawn by BGRA ..The problem comes from the fact that the bitmap is not cleared with an opaque color.
( the upper one is from BGRA, the lower one from Lazarus Canvas )
You use the function Rectangle to do that, but that only draw the edges. You can use FillRectangle instead. Or just Fill to fill everything.With Brush.Color:= xxx procedure Rectangle() also fills the Rect.
.. I suggest you try to play with the Font.Quality property, for example setting it to fqFineClearType.Instead of always redrawing the whole Bitmap in Paint()