List of utility methods to do Color Filter
int | ClippedColorPart(int color) Clipped Color Part if (color < 0) { return 0; } else if (color > 0xFF) { return 0xFF; return color; |
Class> | findCommonElementType(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(); ... |
ColorMatrixColorFilter | getContrastFilter(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; |
ColorMatrixColorFilter | getScaleContrastFilter(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; |
int | getSecondaryColorFromPrimaryColor(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)); |
ColorMatrixColorFilter | getTranslationColorFilter( 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; ... |