Buenas, tengo un incomeniente que no logro resolver en cuanto a que me grabe en un archivo una foto tomada desde la cámara. Estoy sacando desde el ejemplo CameraIntent.
Dejo a continuacion la parte del codigo para ver si me pueden ayudar.
Dejo a continuacion la parte del codigo para ver si me pueden ayudar.
B4X:
Private Sub imgImagen_Click
TakePicture
End Sub
Sub TakePicture
Dim i As Intent
i.Initialize("android.media.action.IMAGE_CAPTURE", "")
'File.Delete(Starter.provider.SharedFolder, tempImageFile)
Dim u As Object = Starter.provider.GetFileUri(tempImageFile)
i.PutExtra("output", u) 'the image will be saved to this path
Try
StartActivityForResult(i)
Catch
ToastMessageShow("Camera is not available.", True)
Log(LastException)
End Try
End Sub
'result arrives here
Sub ion_Event (MethodName As String, Args() As Object) As Object
If Args(0) = -1 Then
Try
Dim in As Intent = Args(1)
If File.Exists(Starter.provider.SharedFolder, tempImageFile) Then
lastPicture = LoadBitmapSample(Starter.provider.SharedFolder, tempImageFile, imgImagen.Width, imgImagen.Height).Rotate(-90)
imgImagen.Bitmap = lastPicture
'File.Copy(Starter.provider.SharedFolder, tempImageFile, File.DirDefaultExternal & "/", "eeee.jpg")
SaveBitmapToFile(imgImagen.Bitmap, File.DirDefaultExternal & "/" ,"eee.PNG")
Else If in.HasExtra("data") Then 'try to get thumbnail instead
Dim jo As JavaObject = in
lastPicture = jo.RunMethodJO("getExtras", Null).RunMethod("get", Array("data"))
End If
Catch
Log(LastException)
End Try
End If
If lastPicture.IsInitialized Then imgImagen.Bitmap = lastPicture
Return Null
End Sub
Sub StartActivityForResult(i As Intent)
Dim jo As JavaObject = GetBA
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
jo.RunMethod("startActivityForResult", Array As Object(ion, i))
End Sub
Sub GetBA As Object
Dim jo As JavaObject
Dim cls As String = Me
cls = cls.SubString("class ".Length)
jo.InitializeStatic(cls)
Return jo.GetField("processBA")
End Sub
Public Sub SaveBitmapToFile(Bitmap1 As Bitmap, Dir As String, FileName As String )
Dim Out As OutputStream = File.OpenOutput(Dir, FileName, False)
Bitmap1.WriteToStream(Out, 100, "PNG") 'or JPEG
Out.Close
End Sub