FMX.CameraRoll Sample
This sample demonstrates how to use TTakePhotoFromLibraryAction to open the Photo Library on your iOS or Android device, retrieve an image from the library and display it on your FireMonkey form.
Contents
Location
You can find the AccessCameraApp sample project at:
- Start | Programs | Embarcadero RAD Studio Athens | Samples and then navigate to:
Object Pascal\Mobile Snippets\CameraRoll
CPP\Mobile Snippets\CameraRoll
- Subversion Repository:
Description
The CameraRoll sample shows how to use media library actions to take photos from the local library of your iOS or Android device. The sample uses the TTakePhotoFromLibrary action to open the Photo Library of your device. Then, you can choose a photo from the library in order to be displayed on your FireMonkey form.
How to Use the Sample
- Navigate to one of the locations given above and open:
- Delphi: AccessCameraApp.dproj.
- C++: AccessCamera.cbproj.
- Select the target platform, iOS and Android supported.
- Press F9 or choose Run > Run.
- Interact with the sample:
- Click the library button to open the Photo Library of your device.
- Select a photo.
- See the photo displayed in your FireMonkey form.
Files
File in Delphi | File in C++ | Contains |
---|---|---|
CameraRoll.dproj |
CameraRoll.cbproj |
The project itself. |
uMain.fmx |
uMain.fmx |
The main form where the components are located. |
uMain.pas |
CameraRollPCH.h, CameraRoll.cpp |
Used to define and implement the sample. |
Information.txt |
Information.txt |
Further information about the sample. |
Classes
TCameraRollForm is the main form that represents the main window of the sample. It contains the following components:
- A TActionList object with a media library action:
- A TTakePhotoFromLibrary action
- A TImage object.
- A ToolBar object with a Tbutton and a TLabel object.
Implementation
- The sample uses TTakePhotoFromLibraryAction to take photos from the Photo Library of your device.
- The sample uses TImage to display and define 2D image components.
- The sample uses a Tbutton as the component that is attached to the TTakePhotoFromLibrary action.
When you run the aplication, the sample shows a button at the upper right corner with the stylelookup set to organizetoolbuttonbordered. The TTakePhotoFromLibrary action is attached to this button. If you click the button, the Photo Library opens and allows you to choose a photo. Once the photo has been chosen, the OnDidFinishTaking event assigns the image retrieved from the library to the TImage component in order to be displayed on your FireMonkey form.
Uses
See Also
- Images
- Mobile Tutorial: Taking and Sharing Pictures (iOS and Android)
- Taking and Sharing Pictures and Text Using Action Lists
- Setting Up Action Lists
- Adding an Action to the Action List
Samples
- VCL Image Processing sample
- FireMonkey Image Zoom sample
- FireMonkey Image Rotation sample
- FireMonkey Actions sample
- FireMonkey Access Camera sample
- FireMonkey Share Sheet sample
- Using Picture Dialogs (Delphi)
- Using Picture Dialogs (C++)