iOS Question Can't save the captured photo with camera

Baris Karadeniz

Active Member
Licensed User
Unfortunately I can not save the captured photo with camera. I can't initialize SavePictureToFile sub. I wrote SavePictureToFile sub but I get syntax error (missing parameter) Which parameter should I write for SavePictureToFile?

B4X:
Sub Cam_Complete (Success As Boolean, Image As Bitmap, VideoPath As String)
    If Success Then
        If Image.IsInitialized Then
            vv.View.Visible = False
            ImageView1.Bitmap = Image
            SavePictureToFile ?????
        Else
            vv.View.Visible = True
            vv.LoadVideo(VideoPath, "")
        End If
    End If
End Sub

Sub SavePictureToFile(Data() As Byte, Dir As String, Filename As String, MarkText As String)
    Dim out As OutputStream
    out = File.OpenOutput(File.DirDocuments&"/DirPhoto/", "img.jpg", False)
    out.WriteBytes(Data, 0, Data.Length)
    out.Close
    Dim Job3 As HttpJob
    Job3.Initialize("Job3", Me)
    Job3.PostFile("http://www.xxx/img.php?op=img&imei="&TextFieldimei.Text, File.DirDocuments&"/DirPhoto/", "img.jpg")
End Sub
 

Baris Karadeniz

Active Member
Licensed User
Do I need to use any library for your codes given above? Because when I used the codes you gave into the Sub Cam_Complete as seen below, I receive several logs like; unknown member: close, missing parameter for Dim Out As ...., Undeclared variable "out", types mismatch for the line Image.Write to stream.

B4X:
Sub Cam_Complete (Success As Boolean, Image As Bitmap, VideoPath As String)
    If Success Then
        If Image.IsInitialized Then
            vv.View.Visible = False
            ImageView1.Bitmap = Image
            Dim out As OutputStream = File.OpenOutput(File.DirDocuments, "DirPhoto/img.jpg")
            Image.WriteToStream(out, 100, "JPEG")
            out.Close
            Dim Job3 As HttpJob
            Job3.Initialize("Job3", Me)
            Job3.PostFile("http://www.taksi-m.com.tr/track/server/http/img.php?op=img&imei="&TextFieldimei.Text, File.DirDocuments&"/DirPhoto/", "img.jpg")
        Else
            vv.View.Visible = True
            vv.LoadVideo(VideoPath, "")
        End If
    End If
End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
See the error message. The IDE helps you solve such issues:

test.gif
 
Upvote 0

Baris Karadeniz

Active Member
Licensed User
Thank you. It is Ok now. But when it is downloaded to the server, I receive log error below (Error response: , status code: 500, JobName = Job3, Success = false).

jpg file sometimes sent to the server, sometimes not. Do I need to write FALSE to Dim out As OutputStream.... line?

Class (b4i_httpjob) instance released.
response success
JobName = Job2, Success = true
0
Class (b4i_httpjob) instance released.
Error response: , status code: 500
JobName = Job3, Success = false
Error: unknown error
Class (b4i_httpjob) instance released.
response success
JobName = MyJob, Success = true
response success

My codes are;


B4X:
Sub Cam_Complete (Success As Boolean, Image As Bitmap, VideoPath As String)
    If Success Then
        If Image.IsInitialized Then
            vv.View.Visible = False
            ImageView1.Bitmap = Image
            Dim out As OutputStream = File.OpenOutput(File.DirDocuments, "img.jpg", True)
            Image.WriteToStream(out, 100, "JPEG")
            out.Close
            Dim Job3 As HttpJob
            Job3.Initialize("Job3", Me)
            Job3.PostFile("http://www.xxx.com/img.php?op=img&imei="&TextFieldimei.Text, File.DirDocuments, "img.jpg")
        Else
            vv.View.Visible = True
            vv.LoadVideo(VideoPath, "")
        End If
    End If
End Sub
 
Upvote 0
Top