CameraDemo

CameraDemo is a simple C++ application built with the MoSync SDK that demonstrates how to control a device's camera. It makes use of the MoSync Widget C API.

Main screen, AndroidMain screen, iOS/iPhoneSettings screen, Android

This example is included in the MoSync SDK installation in the /examples folder. For information on importing the examples into your workspace, see Importing the Examples.

Behaviour

The application makes extensive use of the MoSync Widget API. It has three different screens:

  • MainScreen is the default screen in the application form which the user can take snapshots, zoom in or out (if supported by the device), reach the other screens.
  • SettingsScreen contains controls for configuring the camera and setting its properties. It also provides the ability to switch between cameras, where that is supported. This screen may differ from one device to another based on the available functionality on the device. 
  • ImageScreen contains the latest captured image.

In the Code

The project is divided into several files. Each screen is implemented in a separate set of header and cpp files.

The main.cpp file is the main file of the project. It includes the code for creating MainScreen.

ImageScreen.cpp contains the code for creating and handling the ImageScreen, while  SettingScreen.cpp implements a class that creates and handles the SettingsScreen.

WidgetUtil.cpp contains simple wrappers for setting and getting properties of the widgets (similar to the files seen in our example application HelloNativeUI).

The .h header files contain the forward declarations for the code in the .cpp files.

Touch responses

  • Tap buttons to capture image, switch screens, zoom in/out.