Sub Process_Globals
Private xui As XUI
Private rp As RuntimePermissions
End Sub
Sub Globals
Private ImageView1 As ImageView
Private FileDir, FileName As String
Private bmpTest0, bmpTest1 As B4XBitmap
Private cvsTest As B4XCanvas
Private rectTest As B4XRect
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
'loads the bitmap
bmpTest0 = xui.LoadBitmap(File.DirAssets, "image0.jpg")
Log("Bitmap width = " & bmpTest0.Width)
Log("Bitmap height = " & bmpTest0.Height)
'crops the bitmap
bmpTest1 = bmpTest0.Crop(0, 0, bmpTest0.Width / 2, bmpTest0.Height / 2)
'draws the croped bitmap on the screen
rectTest.Initialize(10dip, 200dip, 10dip + ImageView1.Width / 2, 200dip + ImageView1.Height / 2)
cvsTest.Initialize(Activity)
cvsTest.DrawBitmap(bmpTest1, rectTest)
'saves the croped bitmap
FileDir = rp.GetSafeDirDefaultExternal("")
Log(FileDir)
FileName = "Test1.jpg"
bmpTest1.WriteToStream(File.OpenOutput(FileDir, FileName, False), 100, "JPEG")
End Sub