B4J Question ImageView not show image

Toley

Active Member
Licensed User
Longtime User
Hi, can you tell me what is missing in this simple code to view the image in ImageView? I am surely missing something obvious.

B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private ImageView1 As ImageView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("imgview") 'Load the layout file.
    MainForm.Show
    ImageView1.SetImage(fx.LoadImage(File.DirApp & "\Images", "Android.bmp"))
End Sub

The image is in the correct folder (no path error), ImageView1 was added with the designer and is the same size as the image.
 

Daestrum

Expert
Licensed User
Longtime User
Are you sure it can load a bmp file, as I have only used png or jpg images.
Maybe try loading into an Image control then use that for the ImageView.SetImage(img)
 
Upvote 0

Toley

Active Member
Licensed User
Longtime User
Are you sure it can load a bmp file, as I have only used png or jpg images.
Maybe try loading into an Image control then use that for the ImageView.SetImage(img)
You are right, it cannot load bmp files. Works fine with jpg.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
If you need to use a bitmap then loading it into an Image and then into the imageview will work.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…