FMX.Mobile.PhotoEditorDemo Sample (Object Pascal)
This sample illustrates how to apply effects to photos taken from the mobile device or from the built-in camera and how to save the customized photo to the library using FireMonkey.
You can find the FireMonkeyMobile PhotoEditorDemo sample project at:
- Start | Programs | Appmethod 1.16 | Samples and then navigate to either:
Object Pascal\Mobile Samples\Media\PhotoEditorDemo
- Subversion Repository for Object Pascal: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RadStudio_XE8//Object%20Pascal/Mobile%20Samples/Media/PhotoEditorDemo
- Subversion Repository for C++: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RadStudio_XE8//CPP/Mobile%20Samples/Media/PhotoEditorDemo
The top toolbar of the application has a set of buttons with different effects and a button to take a photo from the local library. The set of effects depends on the device on which the application runs.
- For iPhone, there are three effects available:
- For iPad, there are eight effects available:
The lower toolbar contains three buttons:
- A button that opens the share sheet and offers the possibility to share or save the managed photo.
- A button for taking photos.
- A button that clears the image container.
How to Use the Sample
- Navigate to the one of the locations given above, and open:
- Object Pascal: PhotoEditorDemo.dproj
- C++: PhotoEditorDemo.cbproj
- Press F9 or choose Run > Run.This is the application layout on an iPhone and an iPad:
- Load or take a photo.
- Edit the photo by applying an effect through the buttons on the top toolbar.
- Save or share the edited image through the Share button on the lower toolbar.
Contains the base form.
Contains the form used when the application runs on an iPad.
Contains the form used when the application runs on an iPhone.
Contains the arrow images used as help when the application runs on iPad.
- TBaseMainForm is the base form of the application. This class contains the following:
- Four TButton objects for taking photos from camera, taking photos from local library, sharing the current used photo, and clearing the photo container.
- Four TSpeedButton objects to apply the image effects.
- Two TToolBar objects.
- A TImage to display the used image.
- An TActionList objects with:
- A TLayout.
- A TFloatAnimation used to animate the deletion process.
- The TPadMainForm class is derived from TBaseMainForm. It is the main form for the application when running on an iPad device. TPadMainForm extends the TBaseMainForm class with the following components:
- The TPhoneMainForm class is derived from TBaseMainForm. It is the main form for the application when running on an iPhone device. TPhoneMainForm extends the TBaseMainForm class with the following component:
- A TText to display the help text.
This application uses TAction and TFilterManager to load and customize images. The SetEffect method of the TBaseMainForm class uses TFilterManager to access FireMonkey image effects by name, through the FilterByName method, and then sets the various effects attributes. Each action assigned to an effect button calls the SetEffect method.
All the buttons on the application forms have attached actions.
The form to be open at run time is set in the PhotoEditorDemo.dpr file. To see the PhotoEditorDemo.dpr, right-click the project in the Project Manager and choose View source.