[SOLVED] BGRABitmap Rotate lazarus / 39-Graphics ---------------------------------------------------------------------- Handoko · 2020-08-08 15:23 I want to rotate the icon on its center and draw it on the center of the form. But I can't make it work correctly. How to fix it? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, ExtCtrls,  BGRABitmap, BGRABitmapTypes, BGRATransform; type   { TForm1 }   TForm1 = class(TForm)    Timer1: TTimer;    procedure FormCreate(Sender: TObject);    procedure Timer1Timer(Sender: TObject);  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } var  Image: TBGRABitmap;  Tick:  Integer; procedure TForm1.Timer1Timer(Sender: TObject);var  Temp:   TBGRABitmap;  Affine: TBGRAAffineBitmapTransform;begin  Inc(Tick);  Temp := TBGRABitmap.Create(ClientWidth, ClientHeight, BGRAWhite);  Affine := TBGRAAffineBitmapTransform.Create(Image);  Affine.Translate(-Image.Width div 2, -Image.Height div 2);  Affine.RotateDeg(Tick);  Temp.FillPolyAntialias([PointF(0, 0), PointF(ClientWidth, 0),    PointF(ClientWidth, ClientHeight), PointF(0, ClientHeight)], Affine);  Affine.Free;  Temp.Draw(Canvas, ClientWidth div 2, ClientHeight div 2);  Temp.Free;end; procedure TForm1.FormCreate(Sender: TObject);begin  Image := TBGRABitmap.Create('project1.ico');end; end.Requirement: BGRABitmap package ---------------------------------------------------------------------- circular · 2020-08-08 15:49 You need to add a Translate after the Rotate to restore the center position. Code: [Select]  Temp := TBGRABitmap.Create(ClientWidth, ClientHeight, BGRAWhite);   Affine := TBGRAAffineBitmapTransform.Create(Image);   Affine.Translate(-Image.Width div 2, -Image.Height div 2);   Affine.RotateDeg(Tick);   Affine.Translate(Image.Width div 2, Image.Height div 2);   Temp.Fill(Affine);   Affine.Free;   Temp.Draw(Canvas, 0, 0);   Temp.Free; ---------------------------------------------------------------------- Handoko · 2020-08-08 17:32 That works. But I keep using FillPolyAntialias because Fill(Affine) will give black background. Thanks circular. ---------------------------------------------------------------------- circular · 2020-08-08 19:53 Oh ok. You can add dmDrawWithTransparency parameter to Fill. It is in principle slightly faster. ---------------------------------------------------------------------- Handoko · 2020-08-09 03:07 Yes, Temp.Fill(Affine, dmDrawWithTransparency); is what I need. Thank you. ---------------------------------------------------------------------- circular · 2020-08-09 06:58 You're welcome