#Region Project Attributes
#ApplicationLabel: provacaricafoto2
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Layout1")
Private original As ImageView
original.Initialize("ResizeImage")
original.Bitmap=(LoadBitmap(File.DirRootExternal, "Sofia.jpg"))' percorso telefonino
ResizeImage(original,320,480)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub ResizeImage(original As Bitmap, TargetX As Int, TargetY As Int) As Bitmap
Dim origRatio As Float = original.Width / original.Height
Dim targetRatio As Float = TargetX / TargetY
Dim scale As Float
If targetRatio > origRatio Then
scale = TargetY / original.Height
Else
scale = TargetX / original.Width
End If
Dim c As Canvas
Dim b As Bitmap
b.InitializeMutable(TargetX, TargetY)
c.Initialize2(b)
'set the background
c.DrawColor(Colors.LightGray)
Dim r As Rect
Dim w = original.Width * scale, h = original.Height * scale As Int
r.Initialize(TargetX / 2 - w / 2, TargetY / 2 - h / 2, TargetX / 2 + w / 2, TargetY / 2+ h / 2)
c.DrawBitmap(original, Null, r)
Return b
End Sub