Use the camera on mobile device to take photos or access the photo library on mobile device.
An enum value indicates where the image is sourced. Valid options:
CAM: take photo from camera
LIB: select photo from photo library
A Boolean value indicates if enable or disable the device to take a photo.
A Boolean value indicates if enable or disable the device to take a video.
A Boolean value indicates if the photo should be saved to the gallery.
A Boolean value indicates if return the image data as a base64 encoded string.
A Boolean value specifies whether return the path and URL of the image or video file.
A Boolean value indicates whether allow users to do some editing on the image or video clip like scaling. The editing features are device specific.
A Boolean value indicates whether allow annotation on photo taken from camera or album
An enum value to select quality level of the video. Valid options:LOW,MED,HIGH
An integer value specifies the limit length of video to this number of seconds. Set value to 0 for no maximum.
A string value specifies a fully qualified path of the file that will be created by the camera.
A string value contains the logical path of the image or video file.
A string value contains the URL of the image or video file
A Boolean value that tell user if an image has been taken
A Boolean value that tell user if a video has been recorded.
A string value that contains the image data encoded as base64.
Activate the camera on the device.
Set the size of image. For actual image size, set width and height to 0.
Input Arguments:
Name | Type | Mandatory | Description |
|---|---|---|---|
Orientation | Enum | Yes | Specify whether the size applies to a specific orientation. If so, the size will be flipped for the alternate orientation. |
Width | Integer | Yes | Image width |
Height | Integer | Yes | Image height |
Specify the size of the image when it is encoded for base64. To use the image size settings, set width and height to 0.
Input Arguments:
Name | Type | Mandatory | Description |
|---|---|---|---|
Orientation | Enum | Yes | Specify whether the size applies to a specific orientation. If so, the size will be flipped for the alternate orientation. |
Width | Integer | Yes | Image width |
Height | Integer | Yes | Image height |
Triggered when an image/video has been taken/recorded.
Name | Type | Description |
|---|---|---|
Status | Enum | See Status Code |
Message | String |
Recommended code: If taking a video, return the data as a file (ReturnFile := true) and set ReturnBase64String to false.
Define_Com Class(#xDeviceCamera) Name(#CameraUse)
Evtroutine Handling(#COM_OWNER.Initialize)
#ActivateCamera.Enabled := false
Endroutine
Evtroutine Handling(#CameraUse.Initialize)
#ActivateCamera.Enabled := true
Endroutine
Evtroutine Handling(#ActivateCamera.Click)
#CameraUse.Source := CAM
#CameraUse.EnableImage := true
#CameraUse.EnableVideo := false
#CameraUse.SetImageSize( PORT #ImageSizeWidth.Value.AsInteger #ImageSizeHeight.Value.AsInteger )
#CameraUse.SaveToPhotoGallery := true
#CameraUse.ReturnBase64String := true
#CameraUse.SetBase64ImageSize( PORT #Base64Width.Value.AsInteger #Base64Height.Value.AsInteger )
#CameraUse.ReturnFile := true
#CameraUse.AllowEdit := false
#CameraUse.EnableAnnotation := true
#CameraUse.VideoQuality := HIGH
#CameraUse.VideoMaxDuration := #VideoMaxDuration.Value.AsNumber
#CameraUse.OutputPath := #OutputPath
#CameraUse.ActivateCamera()
Endroutine
Evtroutine Handling(#CameraUse.Completed) Status(#lstatus) Message(#message)
If (#lstatus = OK)
#GeneratedFile := #CameraUse.OutputFile
#GeneratedFileUrl := #CameraUse.OutputUrl
If (#CameraUse.IsImage)
#GeneratedType := 'Image'
Else
#GeneratedType := 'Video'
Endif
If (#CameraUse.ImageAsBase64Data <> "")
#Base64 := #CameraUse.ImageAsBase64Data
#LastImage.FileName := "data:image/png;base64," + #CameraUse.ImageAsBase64Data
Endif
Else
#Status := #message
Endif
#Status := #lstatus
Endroutine
Write to a local file (xDeviceFileWrite)
Define_Com Class(#xDeviceFileWrite) Name(#FileWriter
Evtroutine Handling(#COM_OWNER.Initialize)
#Write.Enabled := false
Endroutine
Evtroutine Handling(#FileWriter.Initialize)
#Write.Enabled := true
Endroutine
Evtroutine Handling(#Write.Click)
#FileWriter.FileName := '/recipes/appleStrudel'
#FileWriter.FileType := BIN
#FileWriter.FileEncoding := UTF8
#FileWriter.DataEncoding := BASE64
#FileWriter.Data := 'Add 3 eggs and 4 cups of sugar'
#FileWriter.Write()
Endroutine
Evtroutine Handling(#FileWriter.Completed) Status(#returnedStatus) Message(#message)
#Status := #returnedStatus
If (#Status <> OK)
#StatusMessage := #message
Endif
Endroutine
Read a local file (xDeviceFileRead
Define_Com Class(#xDeviceFileRead) Name(#FileReader)
Evtroutine Handling(#COM_OWNER.Initialize)
#Read.Enabled := false
Endroutine
Evtroutine Handling(#FileReader.Initialize)
#Read.Enabled := true
Endroutine
Evtroutine Handling(#Read.Click)
#FileReader.FileName := '/recipes/chocolateCake'
#FileReader.FileType := TEXT
#FileReader.FileEncoding := UTF8
#FileReader.DataEncoding := NONE
#FileReader.Read()
Endroutine
Evtroutine Handling(#FileReader.Completed) Status(#returnedStatus) Data(#returnedData) Message(#message)
#Status := #returnedStatus
If (#Status = OK)
#Data := #returnedData
Else
#StatusMessage := #message
Endif
Endroutine