Android Question Replace Color in a Bitmap

chrjak

Active Member
Licensed User
Hey Community,
My question is very simple. Is it possible to replace a color with another in one bitmap? I found already a way to remove a color but no way to replace something...

Thanks for answers
Chris
 

Peter Simpson

Expert
Licensed User
Hello @chrjak,
You need the RSImageProcessing Library. The code below will replace the color Black with the color Red in a jpg. Please look at the attached file. The bottom half of the image is actually black.

B4X:
'RSImageProcessing library needed

    Dim rsie As RSImageEffects   

    Dim ImageViewTemp As ImageView
        ImageViewTemp.Initialize("")

    Dim BitmapTemp As Bitmap
        BitmapTemp.Initialize(File.DirAssets, "Image1.jpg")
        BitmapTemp = rsie.ReplaceColor(BitmapTemp, Colors.Black, Colors.Red)

    ImageViewTemp.Bitmap = BitmapTemp
   
    Activity.AddView(ImageViewTemp, 0dip, 0dip, 100%x, 100%y)
 

Attachments

Last edited:

chrjak

Active Member
Licensed User
wow, thank you all so much!
That helped me really!

@simpson I knew there is somewhere i function :D i already red over this some months before
@Fusseldieb and @derez thanks so much! Now I know how to do a great animation ;)

Thanks again!
 
Top