Getting the swatch out of Black / white dominant Images

Updated 10 February 2017


Long time ago I had written a blog on “Changing background to image” using Palette support library. There I showed you how can we change our layout’s background color as per the Images we are getting from server. You can find it here.

Few days ago I was using this technique to get the visible text color to be shown on an image, but the problem was that I changed between different Swatches and even tried defining a region to the image so that I can get a visible color for my text. Despite trying everything, there was no success, then after a lot of search I came to know that the Palette library actually ignores all the white and black pixels from the image to get the correct value for the swatch and coincidently my image was a white dominant image and thats why I was not been able to get the results.


Actually Palette library applies a default filter while generating the Palette and you can remove that filter using “clearFilters()” method of “” class.

And this simple step just solved my problem. You can also set your own Filters to the your palette using “addFilter()” method of Palette class.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.

Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home