Android Question runtimeException error loading bitmap

tian fang

Member
Licensed User
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

#Region "Views Dim"

#End Region

Dim ImageView1 As ImageView
Private mnuCrop As Button
Private Button1 As Button
End Sub

#Region "Activity cicle events"

Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("layMain")

Scale.Initialize
Scale.ScaleAll(Activity, True)

' If FirstTime Then
' Activity.AddMenuItem("Open an image", "mnuCrop")
' End If

End Sub

Sub Activity_Resume


End Sub

Sub Activity_Pause (UserClosed As Boolean)
' Attention: UserClosed will be True even if orientation changes.
End Sub

#End Region

Sub Activity_KeyPress(KeyCode As Int) As Boolean 'Return True to consume the event
If KeyCode = KeyCodes.KEYCODE_BACK Then
If Not(ConfirmAppExit) Then
Return True
End If
End If
Return False
End Sub

#Region "Views events"

Sub btnAppExit_Click
If ConfirmAppExit Then
CloseApp
End If
End Sub

#End Region

#Region "Methods"

Sub ConfirmAppExit As Boolean
Dim ConfermaUscita As Boolean
Dim Res As Int

Res = Msgbox2("Vuoi davvero uscire dal programma?", _
"Attenzione", "Si", "", "No", Null)
If Res = DialogResponse.NEGATIVE Then
ConfermaUscita = False
Else
ConfermaUscita = True
End If

Return ConfermaUscita
End Sub

Sub CloseApp
ExitApplication
End Sub

#End Region


Sub mnuCrop_Click
Dim CropImage As RSCrop
CropImage.Initialize("CropImage", "image.jpg")
CropImage.CropImage2(True, False, False, False)
End Sub

Sub CropImage_Cropped (Success As Boolean, Pathname As String)
If Success = True Then
ToastMessageShow("Successfully cropped!", True)
ToastMessageShow("Path: " & Pathname, True)
Else
ToastMessageShow(Pathname, False)
End If
End Sub


Sub Button1_Click
If File.Exists(File.DirRootExternal,"image.jpg") Then
ImageView1.Bitmap = LoadBitmap(File.DirRootExternal, "image.jpg")
Else
Msgbox("no","no")
End If
End Sub
 

eurojam

Well-Known Member
Licensed User
Longtime User
welcome and please use code tags or use the "Insert" Button, it makes it easier to read your code...
Image1.png
 
Upvote 0

tian fang

Member
Licensed User
B4X:
[CODE]Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

#Region "Views Dim"

#End Region

    Dim ImageView1 As ImageView
    Private mnuCrop As Button
    Private Button1 As Button
End Sub

#Region "Activity cicle events"

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("layMain")
  
    Scale.Initialize
    Scale.ScaleAll(Activity, True)
  
'    If FirstTime Then
    '    Activity.AddMenuItem("Open an image", "mnuCrop")
'    End If
  
End Sub

Sub Activity_Resume

  
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    ' Attention: UserClosed will be True even if orientation changes.
End Sub

#End Region

Sub Activity_KeyPress(KeyCode As Int) As Boolean 'Return True to consume the event
    If KeyCode = KeyCodes.KEYCODE_BACK Then
        If Not(ConfirmAppExit) Then
            Return True
        End If
    End If
    Return False
End Sub

#Region "Views events"

    Sub btnAppExit_Click
        If ConfirmAppExit Then
            CloseApp
        End If
    End Sub

#End Region

#Region "Methods"

Sub ConfirmAppExit As Boolean
    Dim ConfermaUscita As Boolean
    Dim Res As Int

    Res = Msgbox2("Vuoi davvero uscire dal programma?", _
                      "Attenzione", "Si", "", "No", Null)
    If Res = DialogResponse.NEGATIVE Then
        ConfermaUscita = False
    Else
        ConfermaUscita = True
    End If
  
    Return ConfermaUscita
End Sub

Sub CloseApp
    ExitApplication
End Sub

#End Region


Sub mnuCrop_Click
    Dim CropImage As RSCrop
    CropImage.Initialize("CropImage", "image.jpg")
    CropImage.CropImage2(True, False, False, False)
' ImageView1.Bitmap = LoadBitmap(File.DirRootExternal, "image.jpg")
End Sub

Sub CropImage_Cropped (Success As Boolean, Pathname As String)
   If Success = True Then
      ToastMessageShow("Successfully cropped!", True)
      ToastMessageShow("Path: " & Pathname, True)  
   Else
      ToastMessageShow(Pathname, False)
   End If
End Sub


Sub Button1_Click
    If File.Exists(File.DirRootExternal,"image.jpg") Then
    ImageView1.Bitmap = LoadBitmap(File.DirRootExternal, "image.jpg")  
Else
    Msgbox("no","no")
End If
End Sub
[/CODE]
 
Upvote 0
Top