Android Question [Solved] Shadow when flipping image with transparent background

angel_

Well-Known Member
Licensed User
Longtime User
When I flip an image (.png) with transparency, a shading appears in the transparency area. Is it possible to remove it?

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    
    Dim bmp As Bitmap = xui.LoadBitmapResize(File.DirAssets, "image1.png", ImageView1.Width, ImageView1.Height, True)
    ImageView1.SetBitmap(bmp)
End Sub

Sub Button1_Click
    Dim bmp As B4XBitmap = ImageView1.GetBitmap
    Dim bmc As BitmapCreatorEffects
    bmc.Initialize
    
    Dim bmc_flip As Bitmap = bmc.FlipHorizontal(bmp)
    
    ImageView2.SetBitmap(bmc_flip)
End Sub

Screenshot.png
 

Attachments

  • Flip.zip
    10.6 KB · Views: 143

Erel

B4X founder
Staff member
Licensed User
Longtime User
Update to v1.40 and change the code to:
B4X:
Sub Button1_Click
    Dim bmp As B4XBitmap = ImageView1.GetBitmap
    Dim bmc As BitmapCreatorEffects
    bmc.Initialize
    bmc.ScaleDownImages = False
    Dim bmc_flip As Bitmap = bmc.FlipHorizontal(bmp)
    XUIViewsUtils.SetBitmapAndFill(ImageView2, bmc_flip)
End Sub

Note that for this to work correctly in B4i, you need to load the image with the right size:
B4X:
Sub Button1_Click
    Dim bmc As BitmapCreatorEffects
    bmc.Initialize
    bmc.ScaleDownImages = False
    Dim bmp As Bitmap = xui.LoadBitmapResize(File.DirAssets, "image1.png", ImageView1.Width * bmc.ImageScale, ImageView1.Height * bmc.ImageScale, True)
    Dim bmc_flip As Bitmap = bmc.FlipHorizontal(bmp)
    XUIViewsUtils.SetBitmapAndFill(ImageView2, bmc_flip)
End Sub
 
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User
The background is still not transparent like the previous image

Screenshot_20210429.png

Screenshot_20210429_1.png
 

Attachments

  • Screenshot_20210429_1.png
    Screenshot_20210429_1.png
    1.5 KB · Views: 135
Upvote 0
Top