FMX.AccessCameraApp Sample
This sample shows you how to use standard actions to open the camera application, take a picture and retrieve the taken image to display it on your FireMonkey form.
Contents
Location
You can find the AccessCameraApp sample project at:
- Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to:
Object Pascal\Mobile Snippets\AccessCameraApp
CPP\Mobile Snippets\AccessCameraApp
- 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.
Description
The AccessCameraApp sample shows how to use TTakePhotoFromCameraAction to open the camera application on your iOS or Android device, take a picture and retrieve the taken image to display it 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 camera button to open the camera window and take a picture.
Files
File in Delphi | File in C++ | Contains |
---|---|---|
AccessCameraApp.dproj |
AccessCamera.cbproj |
The project itself. |
uMain.fmx |
uMain.fmx |
The main form where the components are located. |
uMain.pas |
AccessCameraPCH.h, AccessCamera.cpp |
Used to define and implement the sample. |
Information.txt |
Information.txt |
Further information about the sample. |
Classes
TAccessCameraAppForm is the main form that represents the main window of the sample. It contains the following components:
- A TActionList object.
- A TTakePhotoFromCameraAction object
- A TImage object.
- A ToolBar object with a Tbutton and a TLabel object.
Implementation
- The sample uses TTakePhotoFromCameraAction to take photos from the camera device.
- The sample uses TImage to display and define 2D image components.
When you run the aplication, the sample shows a picture and a button with the stylelookup set to cameratoolbuttonbordered. The TTakePhotoFromCameraAction is attached to this button. If you click the button, the camera window is displayed and allows you to choose the camera to be used (front or back) and to take a photo. Once the photo has been taken, the OnDidFinishTaking event assigns the image retrieved from the camera to the TImage component.
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 Camera Roll sample
- FireMonkey Share Sheet sample
- Using Picture Dialogs (Delphi)
- Using Picture Dialogs (C++)