Android Question Error loading bitmap

Oceaneml

Member
Licensed User
Longtime User
Hello, I am a new user and I need some help.
I get an error on runtime but not in step by step debug mode.

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim Job_cmd As HttpJob
    Dim Marche As Button
    Dim Arret As Button
    Dim Logo As ImageView
    Dim Cmd_Cache As String
    Cmd_Cache = "http://ADRESS:PORT/cgi/ptdc.cgi?command=set_relative_pos&posX=100&posY=0"
    Dim Cmd_Home As String
    Cmd_Home = "http://ADRESS:PORT/cgi/ptdc.cgi?command=go_home"
    Dim Camera As String
    Camera = "http://ADRESS:PORT/image/jpeg.cgi"
    Dim Photo As Boolean
    Dim Bt_Marche As Boolean
    Dim Bt_Arret As Boolean
    Bt_Marche = True
    Bt_Arret = True
    Photo = True
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("testipcam")
    Job_cmd.Initialize("Job_cmd","")
    Job_cmd.Username = "USER"
    Job_cmd.Password = "PASSWORD"
    Pause (1)
    Job_cmd.Download(Camera)            ' Work whithout error on the first call *******************
End Sub

Sub JobDone(Job As HttpJob)
    If Job.Success = True Then
        If Photo = True Then
            Logo.Bitmap = Job.GetBitmap    ' Run time exception - Error loading bitmap after the first call *****************
                                        ' BUT work well in step by step debug mode !
            Photo = False
        End If
    End If
    Job.Release
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Pause(Seconde As Int)
  Dim Temps As Long
  Temps = DateTime.Now + (Seconde * 1000)
  Do While DateTime.Now < Temps
      DoEvents
  Loop
End Sub

Sub Arret_Click
    If Bt_Arret = True AND Bt_Marche = True Then
        Bt_Arret = False
        Job_cmd.download(Cmd_Cache)
        Pause(5)
        Photo = True
        Job_cmd.Download(Camera)        ' When call, error in ligne 54, BUT image is still correctly loaded ! ********************
        Pause(1)
        Bt_Arret = True
    End If
End Sub

Sub Marche_Click
    If Bt_Arret = True AND Bt_Marche = True Then
        Bt_Marche = False
        Job_cmd.download(Cmd_Home)
        Pause(5)
        Photo = True
        Job_cmd.Download(Camera)        ' When call, error in ligne 54, BUT image is still correctly loaded ! ********************
        Pause(1)
        Bt_Marche = True
    End If

See the comment with *******
I try many thing but no result
I think that there is a problem with a close or a reset view ?
Thanks
 

Oceaneml

Member
Licensed User
Longtime User
The first step will be to remove the Pause sub you created. It will only cause problems. You can download the two images at the same time. Just use two HttpJob objects.

The program is used to control a cameraIP
At the beginning I have an image in "logo".
Depending on the position of the camera, I want to move and see the new position.
So I can not load all at first, but step by step in the program.
 
Upvote 0
Top