Replace one color with another.

199 views
Skip to first unread message

Mark F

unread,
Jul 9, 2021, 5:56:28 AM7/9/21
to skia-discuss

Hi,

I start with an image of a blue t-shirt on a white background. I want to replace the white with the transparent color.

How can I achieve this?

Thanks

Mark.

Brian Salomon

unread,
Jul 9, 2021, 1:39:12 PM7/9/21
to skia-d...@googlegroups.com
You could write a custom SkColorFilter using SkRuntimeEffect that looks at the input color from a drawImage and does the color transformation that you want. Simple version would be something like this:


(This doesn't actually run on fiddle.skia.org but does run work when building Skia locally)

Brian

--
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/700aa9a7-88a7-42de-a346-373bd45bd005n%40googlegroups.com.

Brian Salomon

unread,
Jul 9, 2021, 1:52:06 PM7/9/21
to skia-d...@googlegroups.com

Mark F

unread,
Jul 10, 2021, 2:49:36 AM7/10/21
to skia-d...@googlegroups.com
Hi Brian,

Thank you very much. Skia is an awesome library.

Mark.

You received this message because you are subscribed to a topic in the Google Groups "skia-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/skia-discuss/RFOcoin5YsM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/CAHOuern1HH4w4Q65NXoHetQzaivmqRQq7xCpj6m4wf8OHsFV2w%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages