hi i make a simple code using the google and intent *-*
This code is very very simple and call the native crop later save the image
with native camera or galery
here is a example
This code is very very simple and call the native crop later save the image
with native camera or galery
B4X:
#Region Project Attributes
#ApplicationLabel: asd
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: False
#End Region
Sub Process_Globals
End Sub
Sub Globals
Private ImageView1 As ImageView
Private Button1 As Button
Private Button2 As Button
Dim onoff As Boolean
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
End Sub
Sub Activity_Resume
If onoff = True Then
onoff=False
ImageView1.Visible = True
ImageView1.Bitmap = LoadBitmapSample(File.DirRootExternal, "1.jpg",ImageView1.Width, ImageView1.Height)
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
camera(File.DirRootExternal, "1.jpg")
End Sub
Sub Button2_Click
Galeria(File.DirRootExternal, "1.jpg")
End Sub
''''''''''''''''''''''''''''''''''''' CAMERA + CROP '''''''''''''''''''''''''''''''''''''''''''''
Sub camera(Directory As String, PictureName As String)
Dim i As Intent
onoff = True
i.Initialize("android.media.action.IMAGE_CAPTURE", "" )
i.PutExtra("crop", "true") 'crop ON
i.PutExtra("aspectX", 0) 'crop aspects
i.PutExtra("aspectY", 0) 'crop aspects
i.PutExtra("outputX", 200) 'crop size
i.PutExtra("outputY", 150) 'crop size
i.PutExtra("output", ParseUri("file://" & File.Combine(Directory, PictureName))) 'output folder you set OpenCam(File.DirRootExternal, "1.jpg")
StartActivity(i)
End Sub
Sub ParseUri(FileName As String) As Object
Dim r As Reflector
Return r.RunStaticMethod("android.net.Uri", "parse", Array As Object(FileName), Array As String("java.lang.String"))
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''' GALERY+ CROP '''''''''''''''''''''''''''''''''''''''''''''
Sub Galeria(Directory As String, PictureName As String)
Dim i As Intent
onoff = True
i.Initialize(i.ACTION_PICK, "")
i.SetType("image/*")
i.PutExtra("output", ParseUri("file://" & File.Combine(Directory, PictureName))) 'output folder you set OpenCam(File.DirRootExternal, "1.jpg")
i.PutExtra("crop", "true") 'crop ON
i.PutExtra("aspectX", 0) 'crop aspects
i.PutExtra("aspectY", 0) 'crop aspects
i.PutExtra("outputX", 200) 'crop size
i.PutExtra("outputY", 150) 'crop size
StartActivity(i)
End Sub
here is a example