var angle = 0;
function OnStart() {
lay = app.CreateLayout( "linear", "VCenter,FillXY" );
//our base image
img = app.CreateImage( "Img/Hello World.png", -1, .45 );
lay.AddChild( img );
//temporary image (normally not shown)
imgTemp = app.CreateImage( "Img/Hello World.png", -1, .45 );
imgTemp.SetAutoUpdate( false );
lay.AddChild( imgTemp );
//button
btn = app.CreateButton( "rotate and save", 0.3, 0.1 );
lay.AddChild( btn );
btn.SetOnTouch( rotate );
app.AddLayout( lay );
}
function rotate() {
angle += 45;
imgTemp.Clear();
//draw 'img' rotated
imgTemp.DrawImage( img, 0, 0, 1, 1, angle );
imgTemp.Update();
//save 'imgTemp' with rotated image
imgTemp.Save( app.GetAppPath() + '/Img/rotated.png' );
}
cnv = app.CreateImage("img/heading.jpg");
cnv.Rotate(90);
cnv.Flatten();
cnv.Save("/sdcard/rotated.jpg");