Android Utililty Methods Color Filter

List of utility methods to do Color Filter

Description

The list of methods to do Color Filter are organized into topic(s).

Method

intClippedColorPart(int color)
Clipped Color Part
if (color < 0) {
    return 0;
} else if (color > 0xFF) {
    return 0xFF;
return color;
ClassfindCommonElementType(Collection collection)
Find the common element type of the given Collection, if any.
if (isEmpty(collection)) {
    return null;
Class<?> candidate = null;
for (Object val : collection) {
    if (val != null) {
        if (candidate == null) {
            candidate = val.getClass();
...
ColorMatrixColorFiltergetContrastFilter(float factor)
get Contrast Filter
final float scale = factor + 1f;
final float translation = (-.5f * scale + .5f) * 255f;
final float[] matrix = { scale, 0, 0, 0, translation, 0, scale, 0,
        0, translation, 0, 0, scale, 0, translation, 0, 0, 0, 1, 0 };
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
return filter;
ColorMatrixColorFiltergetScaleContrastFilter(float factor)
get Scale Contrast Filter
final float scale = factor + 1f;
final float[] matrix = { scale, 0, 0, 0, 0, 0, scale, 0, 0, 0, 0,
        0, scale, 0, 0, 0, 0, 0, 1, 0 };
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
return filter;
intgetSecondaryColorFromPrimaryColor(int color, double secondaryColorStrength)
Take a color as input, multiply each of the rgb components by mSecondaryColorStrength and return the new color that results from this.
return ((color & ALPHA_MASK)
        + ((int) ((color & RED_MASK) * secondaryColorStrength) & RED_MASK)
        + ((int) ((color & GREEN_MASK) * secondaryColorStrength) & GREEN_MASK) + ((int) ((color & BLUE_MASK) * secondaryColorStrength) & BLUE_MASK));
ColorMatrixColorFiltergetTranslationColorFilter( int amount)
get Translation Color Filter
final int a = (amount >>> 24);
final int r = (amount >> 16) & 0xFF;
final int g = (amount >> 8) & 0xFF;
final int b = (amount) & 0xFF;
final float[] matrix = { 1, 0, 0, 0, r, 0, 1, 0, 0, g, 0, 0, 1, 0,
        b, 0, 0, 0, 1, a };
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
return filter;
...