you can use the option to keep the image at it's original size and centered within the Image object----
==== Example - Original Size ====
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
img = app.CreateImage( "/Sys/Img/Droid1.png" );
img.SetOnTouch( img_OnTouch );
lay.AddChild( img );
app.AddLayout( lay );
}
function img_OnTouch( ev )
{
if( ev.action=="Down" )
app.ShowPopup( "Ouch!" );
}
==== Example - Stretched ====
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
img = app.CreateImage( "/Sys/Img/Droid1.png", 0.5, 0.7 );
img.SetOnTouch( img_OnTouch );
lay.AddChild( img );
app.AddLayout( lay );
}
function img_OnTouch( ev )
{
if( ev.action=="Down" )
app.ShowPopup( "Aaaargh!" );
}
==== Example - Maintain Aspect ====
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
img = app.CreateImage( "/Sys/Img/Droid1.png", 0.5, -1 );
img.SetOnTouch( img_OnTouch );
lay.AddChild( img );
app.AddLayout( lay );
}
function img_OnTouch( ev )
{
if( ev.action=="Down" )
app.ShowPopup( ev.x[0] + ", " + ev.y[0], "Short" );
}
==== Example - Draw Shapes ====
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
img = app.CreateImage( null, 0.8, 0.8 );
lay.AddChild( img );
img.SetColor( "#8888ff" );
img.SetPaintColor( "#ff0000" );
img.DrawCircle( 0.5, 0.5, 0.1 );
img.DrawRectangle( 0.7, 0.7, 0.05 );
app.AddLayout( lay );
}
==== Example - FontAwesome ====
Some say there should always be **Hello World** code.
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
img = app.CreateImage( null, 0.8, 0.8, "FontAwesome" );
lay.AddChild( img );
img.SetColor( "#99ff99" );
img.SetPaintColor( "#0000dd" );
img.SetTextSize(42);
img.DrawText( "[fa-globe] Hello World!", 0.3, 0.5 );
app.AddLayout( lay );
}