Spanish [SOLUCIONADO] B4I - CAPTURA DE FOTOS

Anton Solans Argemí

Active Member
Licensed User
Estoy desarrollando mi primera aplicación en B4I y no se como realizar lo siguiente:

Tengo una carpeta con el nombre de la app y de allí cuelgan varias carpetas distintas. Una de ellas es la de las imágenes que es donde quiero guardar las fotos que realice a través de una opción de hacer fotos. Estas imágenes quiero que se guarden con un nombre en concreto en este directorio en concreto.

El código que estoy haciendo para hacer las fotos sería el siguiente:

B4X:
'Code module

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Private Page_fcamara As Page
    Private btnTakePicture As Button
    Private cam As Camera
    Private VideoPlayer1 As VideoPlayer
    Private ImageView1 As ImageView
End Sub

Sub show
    If Page_fcamara.IsInitialized=False Then
        Page_fcamara.Initialize("Page_fcamara")
        Page_fcamara.RootPanel.LoadLayout("fcamara")
    End If
    Main.NavControl.ShowPage (Page_fcamara)
    InitCamera
    cam.TakePicture
End Sub

Sub InitCamera
    cam.Initialize("cam", Page_fcamara)
End Sub

Sub btnTakePicture_Click
    InitCamera
    cam.TakePicture
End Sub


Sub Cam_Complete (Success As Boolean, Image As Bitmap, VideoPath As String)
    Dim p As Phone
    If Success Then
        If Image.IsInitialized Then
            VideoPlayer1.BaseView.Visible = False
            ImageView1.Bitmap = Image
            p.AddImageToAlbum(Image)
        End If
    End If
End Sub

Sería correcto?

Como podría guardar la foto en el directorio que quiero con el nombre que quiero?[/code]
 
Last edited:

Anton Solans Argemí

Active Member
Licensed User
Ya he podido realizar mi objetivo haciendo esto:

B4X:
Sub camok_Click

        Dim My_bmp As Bitmap
        My_bmp = camimage.Bitmap
        Dim out As OutputStream
        out = File.OpenOutput(File.DirDocuments, "Photo1.png", False)
        My_bmp.WriteToStream(out, 100, "png")
        out.Close
End Sub

Muchas gracias por vuestra ayuda.
 
Top