Android Color Filter getTranslationColorFilter( int amount)

Here you can find the source of getTranslationColorFilter( int amount)

Description

get Translation Color Filter

Parameter

Parameter Description
amount a parameter

Return

A ColorMatrixColorFilter containing a translation matrix of the provided color

Declaration

public static ColorMatrixColorFilter getTranslationColorFilter(
        int amount) 

Method Source Code

//package com.java2s;
import android.graphics.ColorMatrixColorFilter;

public class Main {
    /**// w w w .  ja  v  a  2s  .co m
     *
     * @param amount
     * @return A ColorMatrixColorFilter containing a translation matrix of the provided color
     */
    public static ColorMatrixColorFilter getTranslationColorFilter(
            int amount) {
        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;
    }
}

Related

  1. ClippedColorPart(int color)
  2. findCommonElementType(Collection collection)
  3. getContrastFilter(float factor)
  4. getScaleContrastFilter(float factor)
  5. getSecondaryColorFromPrimaryColor(int color, double secondaryColorStrength)