Recent

Author Topic: [SOLVED] BGRABitmap, CanvasBGRA  (Read 336 times)

petevick

  • Sr. Member
  • ****
  • Posts: 419
[SOLVED] BGRABitmap, CanvasBGRA
« on: October 03, 2024, 06:22:30 pm »
I'm trying to get to grips with using BGRABitmap. I want to draw on the BGRABitmap.CanvasBGRA. With a TCanvas I can use the Clear procedure to clear any drawn lines etc, but there doesn't appear to be an equivalent for the CanvasBGRA, am I missing something ?
« Last Edit: October 04, 2024, 10:37:36 am by petevick »
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Windows 10, Lazarus 3.2, FPC 3.2.2

paweld

  • Hero Member
  • *****
  • Posts: 1268
Re: BGRABitmap, CanvasBGRA
« Reply #1 on: October 03, 2024, 07:46:42 pm »
Maybe FillRect
Code: Pascal  [Select][+][-]
  1. var
  2.   bmp: TBGRABitmal;
  3. begin
  4.   // ...
  5.   bmp.CanvasBGRA.Brush.Color := clWhite;  
  6.   bmp.CanvasBGRA.FillRect(bmp.CanvasBGRA.ClipRect); // "clear" :-)
  7.   // ...
  8. end;
  9.  
Best regards / Pozdrawiam
paweld

petevick

  • Sr. Member
  • ****
  • Posts: 419
Re: BGRABitmap, CanvasBGRA
« Reply #2 on: October 03, 2024, 08:16:23 pm »
Maybe FillRect
Code: Pascal  [Select][+][-]
  1. var
  2.   bmp: TBGRABitmal;
  3. begin
  4.   // ...
  5.   bmp.CanvasBGRA.Brush.Color := clWhite;  
  6.   bmp.CanvasBGRA.FillRect(bmp.CanvasBGRA.ClipRect); // "clear" :-)
  7.   // ...
  8. end;
  9.  

Yep that does it, but it's not giving  what I'm after, I need to delve deeper I think.
Thanks for the help pawekd  ;)
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Windows 10, Lazarus 3.2, FPC 3.2.2

circular

  • Hero Member
  • *****
  • Posts: 4356
    • Personal webpage
Re: [SOLVED] BGRABitmap, CanvasBGRA
« Reply #3 on: October 06, 2024, 03:27:22 pm »
It is a good point, CanvasBGRA provides methods do draw as the regular Canvas, bit it does not provide a Clear method nor methods to erase according to a certain shape.

As a workaround, you can do bmp.FillTransparent.

I am wondering what would be the methods. Clear seem rather straightforward to clear the whole canvas. Regarding the shapes, maybe we could add a property to the Pen and the Brush to express that they are suppose to erase instead of draw.

Conscience is the debugger of the mind

petevick

  • Sr. Member
  • ****
  • Posts: 419
Re: [SOLVED] BGRABitmap, CanvasBGRA
« Reply #4 on: October 06, 2024, 03:29:58 pm »
It is a good point, CanvasBGRA provides methods do draw as the regular Canvas, bit it does not provide a Clear method nor methods to erase according to a certain shape.

As a workaround, you can do bmp.FillTransparent.

I am wondering what would be the methods. Clear seem rather straightforward to clear the whole canvas. Regarding the shapes, maybe we could add a property to the Pen and the Brush to express that they are suppose to erase instead of draw.
The Pen/Brush property sounds like the better way to me.
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Windows 10, Lazarus 3.2, FPC 3.2.2

 

TinyPortal © 2005-2018