SkTableColorFilter::MakeARGB color issues

22 views
Skip to first unread message

Kirill Grouchnikov

unread,
Nov 9, 2021, 5:25:08 PMNov 9
to skia-discuss
I start with this:

image.png
and a color filter created from these 256 colors (a custom computed table of colors that represents a certain gradient, in this case, green):

image.png

Then, when the filter is applied to the original visuals, it looks like this:

image.png
The visuals are "almost" right, except for that dark brown patch up top, which looks like it took the original bright red and put some green on top of it, instead of re-colorizing it into the matching green.

Under some other filters it may look like this:
image.png
or this:
image.png

It feels like some (perhaps more saturated?) colors retain a lot of their original hue, instead of being remapped into the provided table.

Perhaps I'm misunderstanding what SkTableColorFilter::MakeARGB does? 

Is there a different API to completely remap the colors of the input? Something that computes the brightness of each pixel, and uses that to choose a color specified by the filter, ignoring the original hue?

Kirill Grouchnikov

unread,
Nov 11, 2021, 5:44:51 PMNov 11
to skia-discuss
As my own follow-up on this, I did manage to get much closer to my target visuals by combining SkTableColorFilter::MakeARGB together with SkColorFilters::Matrix configured with a grayscale conversion matrix, making a SkColorFilters::Compose around these two (grayscale as inner, table ARGB as outer):

image.png

Brian Osman

unread,
Nov 11, 2021, 7:24:00 PMNov 11
to skia-d...@googlegroups.com
Yes, that's the right idea. The table color filter applies the table transform to each color channel independently - so it changes the amount of red, based on the original amount, and the table, etc... Converting to grayscale (with a matrix color filter or similar) looks like the thing you're aiming for.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/CANfAXW0%2BdPoA6Dn%3DxWvSOjCqztsjRzrLUfPW6Ko6H-0dDmVR9g%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages