B4J Question load image and put it into imageview?

Discussion in 'B4J Questions' started by ShaneG30, Jun 18, 2015.

  1. ShaneG30

    ShaneG30 Well-Known Member Licensed User

    I'm kinda confused on how to load an Image via a File Chooser and then insert the resulting image into an ImageView.

    Thanks.
     
  2. jmon

    jmon Well-Known Member Licensed User

    It's simple:
    Code:
    Dim SelectImg As FileChooser
    SelectImg.Initialize   
    SelectImg.SetExtensionFilter(
    "Image""*.jpg")
    SelectImg.Title = 
    "Change your photo"
    FileImg = SelectImg.ShowOpen(Main.MainForm)

    If FileImg <> "" Then
        iv.SetImage(fx.LoadImageSample(
    File.GetFileParent(FileImg), File.GetName(FileImg), iv.Width, iv.Height))
        
    'or
        iv.SetImage(fx.LoadImage(File.GetFileParent(FileImg), File.GetName(FileImg))
    end if
    [edit] missnamed the second LoadImage to LoadImageSample
     
    Last edited: Jun 18, 2015
    Erel and ShaneG30 like this.
  3. ShaneG30

    ShaneG30 Well-Known Member Licensed User

    @jmon - Awesome, it works!
     
  4. jmon

    jmon Well-Known Member Licensed User

    Sorry I forgot to say that FileImg should be declared as string.
     
    ShaneG30 likes this.
  5. ShaneG30

    ShaneG30 Well-Known Member Licensed User

    I figured that out ;) It was kinda obvious when FileImg was used to see if a file path existed. Paths are strings, so.....
     
    Last edited: Jun 18, 2015
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice