Jump to content
Kurt G

Install rotating component in RAD 10.4

Recommended Posts

I have installed Delphi RAD 10.4.
I want to install a component to rotate images and have found various guides, but can't get any of them to work.

Is there anyone who can help?


Share this post

Link to post

Since FMX is multi-device platform Windows specific rotation schemes are not usable.  

You simply use the rotation angle in the object inspector.


In samples there's some animation examples that should be helpful. 


procedure TForm19.Button1Click(Sender: TObject);
  btn : TButton;
  btn := Sender as TButton;
  with btn do RotationAngle := RotationAngle + 2;

  btn.Position.X := Width / 2 - btn.Width / 2;   //workaround the rotationcenter business
  btn.Position.Y := Height / 2 - btn.Height / 2;


Share this post

Link to post

Yes, but it's in FMX and I have a hard time doing without the VCL panel at the top, as I don't understand how to find the components in FMX. And I haven't been able to find Rotate in any of the packages for VCL.

Therefore, I would like to have the rotate component installed in the VCL.









Edited by Kurt G
By a mistake google translates icons is inserted! Sorry.

Share this post

Link to post
1 hour ago, Kurt G said:

Yes, but it's in FMX and I have a hard time doing without the VCL panel at the top

Ok FMX has TControls where in VCL windows has TgraphicControls no windows handle and TWinControls. In short FMX controls don't work in VCL. 


To show palette on menu right click on menu and select components.


To install a control into the VCL Palette be in 32 bit mode the IDE is 32 bit and needs any component to be 32 bit and to be made into a DCP so that control can used in the IDE.  It's easy to stick the IDE if control is not well tested.  You could load one control into the dslusr.bpl to get a feel for operation. Under component install existing and select dslusr.bpl. Save the projectgroup somewhere. 


Here's some code to try until you get that package loaded.

procedure RotateBitmapRads(Bmp: TBitmap; Rads: Single; AdjustSize: Boolean;
  BkColor: TColor = clNone);
  C: Single;
  S: Single;
  Tmp: TBitmap;
  OffsetX: Single;
  OffsetY: Single;
  Points: array[0..2] of TPoint;
  C := Cos(Rads);
  S := Sin(Rads);
  Tmp := TBitmap.Create;
    Tmp.TransparentColor := Bmp.TransparentColor;
    Tmp.TransparentMode := Bmp.TransparentMode;
    Tmp.Transparent := Bmp.Transparent;
    Tmp.Canvas.Brush.Color := BkColor;
    if AdjustSize then
      Tmp.Width := Round(Bmp.Width * Abs(C) + Bmp.Height * Abs(S));
      Tmp.Height := Round(Bmp.Width * Abs(S) + Bmp.Height * Abs(C));
      OffsetX := (Tmp.Width - Bmp.Width * C + Bmp.Height * S) / 2;
      OffsetY := (Tmp.Height - Bmp.Width * S - Bmp.Height * C) / 2;
      Tmp.Width := Bmp.Width;
      Tmp.Height := Bmp.Height;
      OffsetX := (Bmp.Width - Bmp.Width * C + Bmp.Height * S) / 2;
      OffsetY := (Bmp.Height - Bmp.Width * S - Bmp.Height * C) / 2;
    Points[0].X := Round(OffsetX);
    Points[0].Y := Round(OffsetY);
    Points[1].X := Round(OffsetX + Bmp.Width * C);
    Points[1].Y := Round(OffsetY + Bmp.Width * S);
    Points[2].X := Round(OffsetX - Bmp.Height * S);
    Points[2].Y := Round(OffsetY + Bmp.Height * C);
    PlgBlt(Tmp.Canvas.Handle, Points, Bmp.Canvas.Handle, 0, 0, Bmp.Width,
      Bmp.Height, 0, 0, 0);

procedure TForm20.Button1Click(Sender: TObject);
  RotateBitmapRads(image1.Picture.Bitmap,2/57,true, Self.Color);









Edited by Pat Foley
should say select ...dslusr.dpk from combobox.
  • Thanks 1

Share this post

Link to post
I have tried the shown program and it works with rotation.
I set it to rotate 45 degrees for each press of the button but then the image moves further down to the right with each press.
Can the routine only be called once?
I show images for four consecutive taps.





Share this post

Link to post


On 10/23/2022 at 2:43 PM, Pat Foley said:

RotateBitmapRads(image1.Picture.Bitmap,2/57, False true, Self.Color);

That will center it.  Darby has examples like this at his DelphiforFun site.   you try Ansus Johnsons Image32 for newer methods.  


Image of FMX


Share this post

Link to post
Yes, but then the corners are cut off.
I'll see if I can find Ansus Johnson's Image32 and try it!


Share this post

Link to post
I have now 'played' with the RotateBitmaps procedure and got it to work as I want. So now I don't need to install the new component. Thanks for the help.

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now