CameraView creates a camera preview control which allows the program to show a live feed of what is currently being seen by the phone / tablet's camera.
Example - Show camera preview
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
cam = app.CreateCameraView( 0.8, 0.4 );
lay.AddChild( cam );
setTimeout( "cam.StartPreview()", 1000 );
app.AddLayout( lay );
}
Example - Take pictures
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
cam = app.CreateCameraView( 0.8, 0.4 );
lay.AddChild( cam );
cam.SetPictureSize( 1024, 768 );
setTimeout( "cam.StartPreview()", 1000 );
btn = app.CreateButton( "Snap", 0.3, -1 );
btn.SetOnTouch( Snap );
lay.AddChild( btn );
app.AddLayout( lay );
}
function Snap()
{
cam.TakePicture( "/sdcard/MyPic.jpg" );
app.ShowPopup("Picture saved");
}
The following methods are avaiable on the CameraView object:
GetColorEffects() ->
string - "none", "mono", "negative", "solarize", "sepia", "positionterize", "whiteboard", "blackboard", "aqua", "vnum_intage-str_cold", "point-blue", "point-red-yellow", "emboss", "sketch", "neon)"
GetPosition(
options ) ->
object - { left: fraction of parent width, top: fraction of parent height, right: fraction of parent width, bottom: fraction of parent height }
number - fraction of screen width
number - fraction of screen height
string - "CIF" or "QVGA" or "SVGA" or "VGA" or "XGA" or "UXGA"
number
set color effects
string - path to file or folder ( "/absolute/..." or "relative/..." )
number - integer
? take multiple pictures?
?
destroys object
destroys object with explode animation and sound
finds num_faces
?
get height in pixels
get width in pixels
?
get available effects
unknown
get screen relative height
GetImageHeight
GetImageWidth
get distance to left parent border
GetMaxZoom
?
"w x h,w x h,..."
string - "rawbase64" or "pngbase64" or "jpgbase64"
number - fraction of object width
number - fraction of object height
get pixel data of given area
get distance to upper parent border
GetVisibility
get screen relative width
get curent zoom
Set visibility "Gone"
HasFlash
Set visibility "Hide"
IsEnabled
app object
return wether obj overlap with an other
IsVisible
?
number - seconds
record for given time
?
?
string -
hexadecimal: "#rrggbb", "#aarrggbb"
colourName: "red", "green", ...
SetBackColor
SetBackColorRadial
changes the background image
string - "none" or "mono" or "negative" or "solarize" or "sepia" or "positionterize" or "whiteboard" or "blackboard" or "aqua" or "vnum_intage"
set effect
string - "Add" or "Multiply" or "?"
adjust color
app object - app image
? like SetPrevImg but multiple?
boolean
en/disable object
SetFlash
string - "Video"
?
move object from current position
function()
?
function()
?
function()
?
function()
called when cam loaded
number - angle in degrees ( 0 - 360 )
? does nothing when tried
set surrounding borders
string
all types
?
set pixel size
SetPosition
? does nothing when tried
? change preview to dso_img?
number - factor
SetScale
change object size
SetSound
set pixel size
string - "Show" or "Hide" or "Gone"
change visibility mode
SetZoom
Set visibility "Show"
start camera & preview on display,needed for flash
stop camera
stop camera
number - percent
?
TakePicture
?
object id