Sub Process_Globals
Private mBmp As Bitmap
End Sub
Sub Globals
Dim sv2d As ScrollView2D
Dim width, height As Int
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.AddMenuItem("Fill Screen", "FitToScreen")
Activity.AddMenuItem("Go back", "GoBack")
End Sub
Sub Activity_Resume
Activity.Invalidate
End Sub
Sub FitToScreen_Click
If sv2d.IsInitialized=False Then Return 'Could be that a Webview is active!
'Rescale bitmap image to fit screen
Dim AspectRate As Double
width=mBmp.width
height=mBmp.height
AspectRate=width/height
If width>90%x Then
'too wide
width=90%x
height=width/AspectRate
Else
'too high
height=90%y
width=height*AspectRate
End If
sv2d.Panel.height=height
sv2d.Panel.width=width
sv2d.Top=(sv2d.height-height)/2
sv2d.Left=(sv2d.width-width)/2
sv2d.Invalidate
End Sub
Sub ShowImage(bmp As Bitmap)
mBmp = bmp
sv2d.Initialize(mBmp.width, mBmp.height, "")
sv2d.Panel.SetBackgroundImage(mBmp)
Activity.AddView(sv2d, 0, 0, 100%x, 100%y)
End Sub
Sub GoBack_Click
If Webview1.IsInitialized Then Webview1.RemoveView
If sv2d.IsInitialized Then sv2d.RemoveView
File.Delete(File.DirRootExternal, Main.ImageFileName)
Activity.Finish
End Sub
'Trap the back button
Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
Activity.OpenMenu
Else
Return False
End If
End Sub