This guide explains how to use the camera of the device in a project.
The basic function of a camera is to capture a photo. The Smartface uses native camera components for capturing a photo with the "SMF.Multimedia.startCamera()" method.
|cameraType||Integer||The camera type can be SMF.Multimedia.CameraType.FRONT or SMF.Multimedia.CameraType.REAR camera.|
|resolution||Integer||The resolution can be SMF.Multimedia.Resolution.SMALL, SMF.Multimedia.Resolution.MEDIUM or SMF.Multimedia.Resolution.LARGE.|
|autoFocus||Boolean||It is set true for auto focus.|
|onStart||Function||Callback function occurs when the camera is started.|
|onCapture||Function||Callback function occurs when the camera captures a photo.|
|onCancel||Function||Callback function occurs when the camera is cancelled.|
|onFailure||Function||Callback function occurs when there is an error.|
Here is the simple code lines of an application which captures a photo;
In general use, the captured photos should be saved to the device gallery. The "Device.Media.saveToGallery()" method is used to save an image to the gallery.
|item||String||The item which will be saved to the Device.|
|name||String||The name of the item which will be saved to the device.|
|onSuccess||Function||Triggers if the item successfully added to the device.|
|onError||Function||Triggers if an error occurs while trying to save the item to the device.|
Here is the simple code lines of an application which captures a photo and saves it to the gallery ;
In the mobile applications, the captured images are generally more useful when they are cropped. The Smartface let developers to use the native crop components. The "SMF.UI.cropImage()" method is used to open the native crop components.
|imageUri||String||The Uri of the image to be cropped. It can be an SMF.Bitmap object, SMF.File object or a string.|
The aspect and output parameters. They can be:
|onSuccess||Function||Triggers after the image is cropped successfully. It returns the new image with “e.imageUri”. The filename pattern will be “crop_[timestamp].[extension]”|
|onError||Function||Triggers if an error happens. The “e.message“ returns the error|
|onCancel||Function||Triggers if the user cancels the crop screen|
Here is the simple code lines of an application which captures a photo , crops the photo and saves it to the gallery ;