Recent

Author Topic: BGRA bitmap canvas2D transform  (Read 1719 times)

simin_sh

  • Full Member
  • ***
  • Posts: 143
BGRA bitmap canvas2D transform
« on: December 02, 2018, 02:21:55 pm »
Hi, I am testing bgra bitmap canvas2d transform, but it does not work, as you can see in the screenshot that I attached, I set translate to (100, 100), but it does not work, any suggestion?
Regards

Code: Pascal  [Select][+][-]
  1.  
  2. procedure TForm1.FormCreate(Sender: TObject);
  3. begin
  4.   bmp := TBGRABitmap.Create(100, 100, BGRA(255, 0, 0));
  5.   with bmp.Canvas2D do
  6.   begin
  7.     save;
  8.     translate(100, 100);
  9.     restore;
  10.   end;
  11. end;
  12.  
  13. procedure TForm1.FormPaint(Sender: TObject);
  14. begin
  15.   bmp.Draw(Canvas, 0, 0);
  16. end;    
  17.  
OS Windows 10 - Lazarus 1.7 - FPC 3.1.1

lainz

  • Hero Member
  • *****
  • Posts: 3763
  • Leandro Diaz
Re: BGRA bitmap canvas2D transform
« Reply #1 on: December 02, 2018, 02:26:40 pm »
The problem is that you're not drawing nothing inside to translate. You're creating a canvas of 100 by 100 pixels background color red. Drawing nothing with Canvas2D-

simin_sh

  • Full Member
  • ***
  • Posts: 143
Re: BGRA bitmap canvas2D transform
« Reply #2 on: December 03, 2018, 06:58:18 am »
The problem is that you're not drawing nothing inside to translate. You're creating a canvas of 100 by 100 pixels background color red. Drawing nothing with Canvas2D-



Thank you so much lainz, that was helpful.
The problem was that I was drawing some fill rectangles and arcs in another test and was not change by translate, but now that you said this, I noticed I was calling canvas2D.restore() before them.
Regards
OS Windows 10 - Lazarus 1.7 - FPC 3.1.1

circular

  • Hero Member
  • *****
  • Posts: 3506
    • Personal webpage
Re: BGRA bitmap canvas2D transform
« Reply #3 on: December 14, 2018, 05:08:02 pm »
Indeed, restore is to be called after the drawings.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018