B4J Question ImageView and PNGs

Discussion in 'B4J Questions' started by techknight, Jul 10, 2019.

  1. techknight

    techknight Well-Known Member Licensed User

    I am having a weird issue.

    I am creating and adding an ImageView to a Panel programattically, but for some weird reason the controls or background that is behind the imageview is showing through slightly on my PNG files, like alpha issues.

    I tried doing Alpha = 1 or using CSSUtils to set the background color, but its not doing anything. Not sure if there is a newer XUI way of doing it, but...

    Here is my code:
    Code:
    Sub SwitchAndInsertView(view As Int) 'Changes the content window to host an Image, or a Video.
        If view = CurrentView Then Return 'If we are requesting the same thing as before, we just simply exit. 
        Main.pnlContent.RemoveAllNodes 'Remove all views from the Panel.
        If view = 1 Then 'We are putting in an image.
            Log("Initializing ImageView"
            
    If imgContent.IsInitialized = False Then
                imgContent.Initialize(
    "imgContent")
            
    End If
            Main.pnlContent.AddNode(imgContent, 
    00, pnlContentWidth, pnlContentHeight)
            imgContent.Alpha = 
    1
            imgContent.Width = pnlContentWidth
            imgContent.Height = pnlContentHeight
            CSSUtils.SetBackgroundColor(imgContent, fx.Colors.ARGB(
    255000))
    '    Else if view = 2 Then 'We are putting in a video
        End If
        CurrentView = 
    view
    End Sub
    After calling that subroutine, I then do this:
    Code:
    Dim img As Image
                    img.Initialize(FM.MediaDIR & PI.SubDir, PI.FileName)
                    imgContent.SetImage(img) 
    'Set the content to the specific image
                    imgContent.Visible = True
    any ideas?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Is the image semi-transparent? Can you upload it?
     
  3. techknight

    techknight Well-Known Member Licensed User

    Potentially it is? But I figured even if it was, I could set the alpha or backcolor property, or something and it would kill that off....

    See the system I am trying to deploy, I will have no control over the image content a person puts up there. So I need to be able to handle things like this.
     

    Attached Files:

  4. Daestrum

    Daestrum Well-Known Member Licensed User

    Top of my head solution - put a white canvas behind the imgContent in pnlContent.
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Put the ImageView in a Panel and set the panel color.
     
  6. techknight

    techknight Well-Known Member Licensed User

    Ok I can do that, but I am curious why it happens though.

    Any particular reason? something Java FX oriented? or?
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    The image is semitransparent so you can see the layout behind the ImageView. ImageView is made of a single layer, there is no color behind it once you set the image.
     
  8. techknight

    techknight Well-Known Member Licensed User

    Ah so when an image is set, it replaces the colordrawable property. Ok then.
     
    Erel likes this.
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