Android Question Problem loading the image

Khalid.

Member
The image is not loaded only when the screen is flipped horizontally, as shown in the Video
B4X:
Sub Process_Globals
Private xui As XUI
Public Chooser As ContentChooser
Public ImageDir = File.DirAssets As String
Public ImageFileName = "image0.jpg" As String

End Sub

Sub Globals
Private bmpRose As B4XBitmap
Private imvOriginal As B4XView
Private bmcRose As BitmapCreator

End Sub

Sub Activity_Create(FirstTime As Boolean)

Activity.LoadLayout("Layout")

bmpRose = xui.LoadBitmap(ImageDir, ImageFileName)
bmcRose.Initialize(bmpRose.Width, bmpRose.Height)
bmcRose.CopyPixelsFromBitmap(bmpRose)
imvOriginal.SetBitmap(bmpRose)
imvOriginal.As(ImageView).Gravity = Gravity.FILL

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub btnLoadImage_Click
Chooser.Initialize("Chooser")
Chooser.Show("image/*", "Select an image")

End Sub



Private Sub Chooser_Result (Success As Boolean, Dir As String, FileName As String)

If True Then
ImageDir = Dir
ImageFileName = FileName
End If

End Sub
 

Attachments

  • 1647903375009_load image.zip
    55.4 KB · Views: 66
Solution
The problem is that after loading the image you do nothing !
The code below works as you expect.

B4X:
Private Sub Chooser_Result (Success As Boolean, Dir As String, FileName As String)
    If True Then
        ImageDir = Dir
        ImageFileName = FileName
        imvOriginal.SetBitmap(xui.LoadBitmapResize(ImageDir, ImageFileName, imvOriginal.Width, imvOriginal.Height, True))
    End If
End Sub

Khalid.

Member
what happen is you put
B4X:
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
ImageDir AssetsDir - ImageFilenameimage0.jpg
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
ImageDir ContentDir - ImageFilenamecontent://com.android.providers.media.documents/document/image%3A4878
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
ImageDir ContentDir - ImageFilenamecontent://com.android.providers.media.documents/document/image%3A4878


** Activity (main) Resume **

When uploading images, they are not displayed the log=
B4X:
ImageDir AssetsDir - ImageFilena
meimage0.jpg
After turning the device over, it will be loaded image the log=
B4X:
ImageFilenamecontent://com.android.providers.media.documents/document/image%3A4878
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
The problem is that after loading the image you do nothing !
The code below works as you expect.

B4X:
Private Sub Chooser_Result (Success As Boolean, Dir As String, FileName As String)
    If True Then
        ImageDir = Dir
        ImageFileName = FileName
        imvOriginal.SetBitmap(xui.LoadBitmapResize(ImageDir, ImageFileName, imvOriginal.Width, imvOriginal.Height, True))
    End If
End Sub
 
Upvote 0
Solution
Top