Android Code Snippet Change / replace pixel colors in an image using RSImageProcessing

SubName: Using RSImageProcessing to change pixel colors
Description: Here is a quick example on how you can use RSImageProcessing to manipulate colors in an image.

Check out the attached zip files. One project is a simple traffic light system, the other project is a simple 50/50 color split changer. You need to know the exact color of the pixels that needs changing for this to work.
B4X:
'Requires RSImageProcessing library
'The following code is the example used for the 50/50 colour split.

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")

    Dim RSIE As RSImageEffects

    Dim ImageViewTemp As ImageView
        ImageViewTemp.Initialize(Null)

    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)
End Sub

Tags: Image, Pixel, Change, Color
 

Attachments

  • change_colour.zip
    7.2 KB · Views: 671
  • traffic_lights.zip
    70.3 KB · Views: 640
Last edited:

sn_nn

Member
Licensed User
Longtime User
Hello! Works well!
Can i use RSImageProcessing for Fast replasing black pixels by pixel with diffrent range of Red?
(for example: if RGB(Red) component in pixel is more then 155 then replace black pixel)
 
Top