Android Question Reverse colours and do mirror image of FontAwesome or Material icons

RB Smissaert

Well-Known Member
Licensed User
Longtime User
For some button images I need to reverse the colours.
Also I have a button where the Material icon image needs to be flipped left to right (mirror image).
What would be the simplest way to do these things?

RBS
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
For sure your solution and @TILogistic solution are more elegant and correct and will work with any characters.
I post even my idea, simpler but for sure limited in case you need to make the same thing with many many buttons.
Thanks, will have a look at that.
I only needed this really for one (keyboard) button as there is no good forward delete button in the FontAwesome images or Material icon images.

RBS
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Check out these solutions, while I find the color changing solution I developed to convert to SVG.
But it is based on the Flooding algorithm
and
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
EDIT
B4X:
    Dim Bmp As B4XBitmap = FontToBitmap(Chr(0xE14A), xui.CreateMaterialIcons(100), 100, xui.Color_Black)
 
    B4XImageView1.Bitmap = Bmp
    B4XImageView1.mBackgroundColor = xui.Color_Transparent
    B4XImageView1.Update


    Dim bce As BitmapCreatorEffects
    bce.Initialize
    Dim NewBmp As B4XBitmap = bce.ReplaceColor(Bmp, xui.Color_Black, xui.Color_Red, True)
    NewBmp = bce.FlipHorizontal(NewBmp)
    
    B4XImageView2.Bitmap = NewBmp
    B4XImageView2.mBackgroundColor = xui.Color_Transparent
    B4XImageView2.Update
 
Last edited:
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Thanks for that and I have switched now from using the Java code to using B4XBitmapEffects and FlipHorizontal, just because it is a bit
clearer what is going on and giving me more control over the bitmaps.
I stick with using the posted icon file, rather than changing colours as it is all a bit simpler with the black edge around the image.
All working fine now.

B4X:
Sub ToggleDeleteButton
    
    If     bForwardDelete Then
        If bToggledDeleteButton = False Then
            bmpDeleteForward  = BMCE.FlipHorizontal(bmpDeleteBack)
            bToggledDeleteButton = True
        End If
        Dim cs As CSBuilder
        cs.Initialize.Image(bmpDeleteForward, 35dip, 30dip,False)
        arrKeyboardButtons(38).Text = cs
        arrKeyboardButtonsSymbols(38).Text = cs
    Else
        Dim cs As CSBuilder
        cs.Initialize.Image(bmpDeleteBack, 35dip, 30dip,False)
        arrKeyboardButtons(38).Text = cs
        arrKeyboardButtonsSymbols(38).Text = cs
    End If
    
End Sub

RBS
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…