Android Question Issues with CameraIntent. display and save picture

GMan

Well-Known Member
Licensed User
Longtime User
I am using the CameraIntent to make a picture.
All is working fine, Permissions are set, Preview is shown, Image is taken....but where is it and how can i save it ?

Here is the Command to take a picture:
B4X:
Camera1.TakePicture

I only want to put the taken image in an ImageView
 

DonManfred

Expert
Licensed User
Longtime User
All is working fine, Permissions are set, Preview is shown, Image is taken....but where is it
probably in the folde the app is configured to save them.
Picturesfolder maybe?

As you are calling an intent it is the app you are starting/opening which is responsible where they are saved.

If you use the camera itself (in b4a) you have more control on how to save it.

Best is to upload a small project showing the problem.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I just tried
and here i am able to capture the image and even could be able to save it somewhere.

I don´t know what method you are using....
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
I am also using this sample , but have problems to implement the file section
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
B4X:
Private Sub TakePicture (TargetWidth As Int, TargetHeight As Int)
    Dim i As Intent
    i.Initialize("android.media.action.IMAGE_CAPTURE", "")
    File.Delete(Provider.SharedFolder, tempImageFile)
    Dim u As Object = Provider.GetFileUri(tempImageFile)
    i.PutExtra("output", u) 'the image will be saved to this path
    Try
        Wait For (CallSub(KeepRunningService, "Start")) Complete (Unused As Boolean)
        StartActivityForResult(i)
        Wait For ion_Event (MethodName As String, Args() As Object)
        CallSub(KeepRunningService, "Stop")
        Dim bmp As B4XBitmap
        If -1 = Args(0) Then
            Try
                Dim in As Intent = Args(1)
                If File.Exists(Provider.SharedFolder, tempImageFile) Then
                    Dim Exif As ExifData
                    Exif.Initialize(Provider.SharedFolder, tempImageFile)
                    bmp = LoadBitmapSample(Provider.SharedFolder, tempImageFile, Max(TargetWidth, TargetHeight), Max(TargetWidth, TargetHeight))
                    ' You can copy the tempimagefile to whereever you want....
Log("Orientation: " & Exif.getAttribute(Exif.TAG_ORIENTATION))
                    Select Exif.getAttribute(Exif.TAG_ORIENTATION)
                        Case Exif.ORIENTATION_ROTATE_180 '3
                            bmp = bmp.Rotate(180)
                        Case Exif.ORIENTATION_ROTATE_90 '6
                            bmp = bmp.Rotate(90)
                        Case Exif.ORIENTATION_ROTATE_270 '8
                            bmp = bmp.Rotate(270)
                    End Select
                    bmp = bmp.Resize(TargetWidth, TargetHeight, True)
                Else If in.HasExtra("data") Then 'try to get thumbnail instead
                    Dim jo As JavaObject = in
                    bmp = jo.RunMethodJO("getExtras", Null).RunMethod("get", Array("data"))
                End If
            Catch
                Log(LastException)
            End Try
        End If
        CallSubDelayed3(Me, "Image_Available", bmp.IsInitialized, bmp)
    Catch
        ToastMessageShow("Camera is not available.", True)
        Log(LastException)
        CallSubDelayed3(Me, "Image_Available", False, Null)
    End Try
End Sub

Look at my comment in the code
 
Upvote 0
Top