Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
CodeDelphiRAD Studio

Quickly Rotate An Image With Gestures On iOS And Android In Delphi FireMonkey

It provides a picture and the user can rotate the picture by pressing it with two fingers and rotating them. The image rotates in the direction of your fingers. If you rotate the fingers to the right, the image rotates to the right. If you rotate the fingers to the left, the image rotates to the left.

Location

You can find the ImageRotation sample project at:

  • Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to:
    • Object PascalMobile SnippetsInteractiveGesturesImageRotation
    • CPPMobile SnippetsInteractiveGesturesImageRotation
  • Subversion Repository:
    • You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.

How to Use the Sample

  1. Navigate to one of the locations given above and open:
    • Delphi: ImageRotation.dproj.
    • C++: ImageRotation.cbproj.
  2. Select the target platform, iOS and Android supported.
  3. Press F9 or choose Run > Run.
  4. Press the picture with two fingers and rotate them to see how the image rotates.

Files

File in DelphiFile in C++Contains
ImageRotation.dprojImageRotation.cbprojThe project itself.
ImageRotationU.fmxImageRotationU.fmxThe main form where the components are located.
ImageRotationU.pasImageRotationPCH.hImageRotation.cppUsed to define and implement the sample.
Information.txtInformation.txtFurther information about the sample.

Implementation

  • The sample uses TImage to display and define a 2D image component.
  • The property RotationAngle is used to specify the amount (in degrees) by which the image is rotated from the x-axis.
  • The sample uses the TGestureManager class to manage all the touch and gesturing functionalities of the application.
  • The TGestureEventInfo describes a gesture event. It is a record that contains information about a gesture event. The TGestureEvent type passes a TGestureEventInfo record to the user code.

The sample shows a picture. When the user presses the picture with two fingers, the TGestureEventInfo detects a gesture event. If the user rotates the fingers, the sample calculates the rotation angle in order to rotate the image with the same angle.

The link below will guide you to the original post of Embarcadero:

http://docwiki.embarcadero.com/CodeExamples/Sydney/en/FMX.ImageRotation_Sample

Head over and check out the full source code for the gesture based image rotation on Embarcadero’s GitHub.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Get some love as Delphi turns 26
Related posts
DelphiShowcase

Impressive Logistics Provider ERP And Operations Solution Is Created With Delphi

DelphiShowcase

Astonishing 3D Train Simulation Software Displays Delphi Flexibility

DelphiShowcase

A Brilliant Cloud-Based System For Circuit Boards Is Powered By Delphi

DelphiShowcase

MFL Is A Fun Programming Language That Is Delphi Powered

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES