B4J Question ImageView and PNGs

techknight

Well-Known Member
Licensed User
Longtime 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:
B4X:
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, 0, 0, pnlContentWidth, pnlContentHeight)
        imgContent.Alpha = 1
        imgContent.Width = pnlContentWidth
        imgContent.Height = pnlContentHeight
        CSSUtils.SetBackgroundColor(imgContent, fx.Colors.ARGB(255, 0, 0, 0))
'    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:
B4X:
                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?
 

techknight

Well-Known Member
Licensed User
Longtime 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.
 

Attachments

  • Heritage LED Oval.png
    Heritage LED Oval.png
    133.8 KB · Views: 156
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Top of my head solution - put a white canvas behind the imgContent in pnlContent.
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
Ok I can do that, but I am curious why it happens though.

Any particular reason? something Java FX oriented? or?
 
Upvote 0
Top