How to use the colorMatirxFilter to change orange color to green on a bitmap. Code samples would help. Please add explanation for the ColorMatrixFilter
matrix.
I want to change the theme color based on user's selection.
How to use the colorMatirxFilter to change orange color to green on a bitmap. Code samples would help. Please add explanation for the ColorMatrixFilter
matrix.
I want to change the theme color based on user's selection.
Copyright © 2021 Jogjafile Inc.
As we know orange is not a pure color as Red, Green or Blue. This means that orange has three components,
R
,G
andB
components. Therefore, please try this:1) Convert the orange (three values) to gray (one value) by using
Gray = 0.3*RED + 0.59*GREEN+0.11*Blue
;2) Then, using
ColorMatrixFilter
(see Torious's link) set pixel values of those pixels which you want to change as:Set
ZERO
(0 values) to Red and Blue components (as pixel values). Set the Gray value (we just calculated) to Green component (as pixel value).Then, you get your result.