Read complete story

Getting the swatch out of Black / white dominant Images

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.

Solution:

Actually Palette library applies a default filter while generating the Palette and you can remove that filter using “clearFilters()” method of “Palette.java” 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.

. . .

Comment

Add Your Comment

Be the first to comment.

css.php
Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again
Close