Example usage for android.graphics ColorMatrixColorFilter ColorMatrixColorFilter

List of usage examples for android.graphics ColorMatrixColorFilter ColorMatrixColorFilter

Introduction

In this page you can find the example usage for android.graphics ColorMatrixColorFilter ColorMatrixColorFilter.

Prototype

public ColorMatrixColorFilter(@NonNull float[] array) 

Source Link

Document

Create a color filter that transforms colors through a 4x5 color matrix.

Usage

From source file:com.abewy.android.apps.klyph.messenger.widget.BezelImageView.java

public BezelImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Attribute initialization
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BezelImageView, defStyle, 0);

    setMaskDrawable(a.getDrawable(R.styleable.BezelImageView_maskDrawable));

    setBorderDrawable(a.getDrawable(R.styleable.BezelImageView_borderDrawable));

    mDesaturateOnPress = a.getBoolean(R.styleable.BezelImageView_desaturateOnPress, mDesaturateOnPress);

    a.recycle();/*  w ww.  j a v  a 2  s.c om*/

    // Other initialization
    mBlackPaint = new Paint();
    mBlackPaint.setColor(0xff000000);

    mMaskedPaint = new Paint();
    mMaskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));

    // Always want a cache allocated.
    mCacheBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);

    if (mDesaturateOnPress) {
        // Create a desaturate color filter for pressed state.
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0);
        mDesaturateColorFilter = new ColorMatrixColorFilter(cm);
    }
}

From source file:app.geochat.ui.widgets.BezelImageView.java

public BezelImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Attribute initialization
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BezelImageView, defStyle, 0);

    mMaskDrawable = a.getDrawable(R.styleable.BezelImageView_maskDrawable);
    if (mMaskDrawable != null) {
        mMaskDrawable.setCallback(this);
    }//from  w w w.j  av  a 2s  . c om

    mBorderDrawable = a.getDrawable(R.styleable.BezelImageView_borderDrawable);
    if (mBorderDrawable != null) {
        mBorderDrawable.setCallback(this);
    }

    mDesaturateOnPress = a.getBoolean(R.styleable.BezelImageView_desaturateOnPress, mDesaturateOnPress);

    a.recycle();

    // Other initialization
    mBlackPaint = new Paint();
    mBlackPaint.setColor(0xff000000);

    mMaskedPaint = new Paint();
    mMaskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));

    // Always want a cache allocated.
    mCacheBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);

    if (mDesaturateOnPress) {
        // Create a desaturate color filter for pressed state.
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0);
        mDesaturateColorFilter = new ColorMatrixColorFilter(cm);
    }
}

From source file:ng.codehaven.eko.ui.widgets.RoundedImageView.java

public RoundedImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Attribute initialization
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RoundedImageView, defStyle, 0);

    mMaskDrawable = a.getDrawable(R.styleable.RoundedImageView_RmaskDrawable);
    if (mMaskDrawable != null) {
        mMaskDrawable.setCallback(this);
    }//  w w w .  j  a  v a 2  s  . co  m

    mBorderDrawable = a.getDrawable(R.styleable.RoundedImageView_RborderDrawable);
    if (mBorderDrawable != null) {
        mBorderDrawable.setCallback(this);
    }

    mDesaturateOnPress = a.getBoolean(R.styleable.RoundedImageView_RdesaturateOnPress, mDesaturateOnPress);

    a.recycle();

    // Other initialization
    mBlackPaint = new Paint();
    mBlackPaint.setColor(0xff000000);

    mMaskedPaint = new Paint();
    mMaskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));

    // Always want a cache allocated.
    mCacheBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);

    if (mDesaturateOnPress) {
        // Create a desaturate color filter for pressed state.
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0);
        mDesaturateColorFilter = new ColorMatrixColorFilter(cm);
    }
}

From source file:com.aprz.easy_iosched.ui.widget.BezelImageView.java

public BezelImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Attribute initialization.
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BezelImageView, defStyle, 0);

    mMaskDrawable = a.getDrawable(R.styleable.BezelImageView_maskDrawable);
    if (mMaskDrawable != null) {
        mMaskDrawable.setCallback(this);
    }//from w w w .  j  a va  2s .com

    mBorderDrawable = a.getDrawable(R.styleable.BezelImageView_borderDrawable);
    if (mBorderDrawable != null) {
        mBorderDrawable.setCallback(this);
    }

    mDesaturateOnPress = a.getBoolean(R.styleable.BezelImageView_desaturateOnPress, mDesaturateOnPress);

    a.recycle();

    // Other initialization.
    mBlackPaint = new Paint();
    mBlackPaint.setColor(0xff000000);

    mMaskedPaint = new Paint();
    mMaskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));

    // Always want a cache allocated.
    mCacheBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);

    if (mDesaturateOnPress) {
        // Create a desaturate color filter for pressed state.
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0);
        mDesaturateColorFilter = new ColorMatrixColorFilter(cm);
    }
}

From source file:com.dream.yzbb.wolfkiller.widget.BezelImageView.java

public BezelImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Attribute initialization.
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BezelImageView,
            defStyle, 0);/*from  w  ww  .j ava2  s  . c  om*/

    mMaskDrawable = a.getDrawable(R.styleable.BezelImageView_maskDrawable);
    if (mMaskDrawable != null) {
        mMaskDrawable.setCallback(this);
    }

    mBorderDrawable = a.getDrawable(R.styleable.BezelImageView_borderDrawable);
    if (mBorderDrawable != null) {
        mBorderDrawable.setCallback(this);
    }

    mDesaturateOnPress = a.getBoolean(R.styleable.BezelImageView_desaturateOnPress,
            mDesaturateOnPress);

    a.recycle();

    // Other initialization.
    mBlackPaint = new Paint();
    mBlackPaint.setColor(0xff000000);

    mMaskedPaint = new Paint();
    mMaskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));

    // Always want a cache allocated.
    mCacheBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);

    if (mDesaturateOnPress) {
        // Create a desaturate color filter for pressed state.
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0);
        mDesaturateColorFilter = new ColorMatrixColorFilter(cm);
    }
}

From source file:me.zirko.epidroid.ui.widget.NetworkBezelImageView.java

public NetworkBezelImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Attribute initialization
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NetworkBezelImageView, defStyle, 0);

    mMaskDrawable = a.getDrawable(R.styleable.NetworkBezelImageView_maskDrawable);
    if (mMaskDrawable != null) {
        mMaskDrawable.setCallback(this);
    }/*from  w w  w .j  a va 2  s.c  om*/

    mBorderDrawable = a.getDrawable(R.styleable.NetworkBezelImageView_borderDrawable);
    if (mBorderDrawable != null) {
        mBorderDrawable.setCallback(this);
    }

    mDesaturateOnPress = a.getBoolean(R.styleable.NetworkBezelImageView_desaturateOnPress, mDesaturateOnPress);

    a.recycle();

    // Other initialization
    mBlackPaint = new Paint();
    mBlackPaint.setColor(0xff000000);

    mMaskedPaint = new Paint();
    mMaskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));

    // Always want a cache allocated.
    mCacheBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);

    if (mDesaturateOnPress) {
        // Create a desaturate color filter for pressed state.
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0);
        mDesaturateColorFilter = new ColorMatrixColorFilter(cm);
    }
}

From source file:com.saarang.samples.apps.iosched.ui.widget.BezelImageView.java

public BezelImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Attribute initialization
    final TypedArray a = context.obtainStyledAttributes(attrs,
            com.saarang.samples.apps.iosched.R.styleable.BezelImageView, defStyle, 0);

    mMaskDrawable = a.getDrawable(com.saarang.samples.apps.iosched.R.styleable.BezelImageView_maskDrawable);
    if (mMaskDrawable != null) {
        mMaskDrawable.setCallback(this);
    }//w  w  w. j  a v  a2s  . c om

    mBorderDrawable = a.getDrawable(com.saarang.samples.apps.iosched.R.styleable.BezelImageView_borderDrawable);
    if (mBorderDrawable != null) {
        mBorderDrawable.setCallback(this);
    }

    mDesaturateOnPress = a.getBoolean(
            com.saarang.samples.apps.iosched.R.styleable.BezelImageView_desaturateOnPress, mDesaturateOnPress);

    a.recycle();

    // Other initialization
    mBlackPaint = new Paint();
    mBlackPaint.setColor(0xff000000);

    mMaskedPaint = new Paint();
    mMaskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));

    // Always want a cache allocated.
    mCacheBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);

    if (mDesaturateOnPress) {
        // Create a desaturate color filter for pressed state.
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0);
        mDesaturateColorFilter = new ColorMatrixColorFilter(cm);
    }
}

From source file:com.zeus.ui_case.library.BezelImageView.java

public BezelImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setLayerType(LAYER_TYPE_HARDWARE, null);//?
    // Attribute initialization
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BezelImageView, defStyle, 0);

    mMaskDrawable = a.getDrawable(R.styleable.BezelImageView_maskDrawable);
    if (mMaskDrawable != null) {
        mMaskDrawable.setCallback(this);
    }//  w w w . ja  v a 2 s .  c o  m

    mBorderDrawable = a.getDrawable(R.styleable.BezelImageView_borderDrawable);
    if (mBorderDrawable != null) {
        mBorderDrawable.setCallback(this);
    }

    mDesaturateOnPress = a.getBoolean(R.styleable.BezelImageView_desaturateOnPress, mDesaturateOnPress);

    a.recycle();

    // Other initialization
    mBlackPaint = new Paint();
    mBlackPaint.setColor(0xffff0000);
    mBlackPaint.setAntiAlias(true);

    mMaskedPaint = new Paint();
    mMaskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    mMaskedPaint.setAntiAlias(true);

    // Always want a cache allocated.
    mCacheBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);

    if (mDesaturateOnPress) {
        // Create a desaturate color filter for pressed state.
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0);
        mDesaturateColorFilter = new ColorMatrixColorFilter(cm);
    }
}

From source file:com.zhoumushui.zygoteelastichome.view.BezelImageView.java

public BezelImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setLayerType(LAYER_TYPE_HARDWARE, null);//?
    // Attribute initialization
    final TypedArray a = context.obtainStyledAttributes(attrs, styleable.BezelImageView, defStyle, 0);

    mMaskDrawable = a.getDrawable(styleable.BezelImageView_maskDrawable);
    if (mMaskDrawable != null) {
        mMaskDrawable.setCallback(this);
    }/*from w  w  w .  j a v  a  2 s.  c  o  m*/

    mBorderDrawable = a.getDrawable(styleable.BezelImageView_borderDrawable);
    if (mBorderDrawable != null) {
        mBorderDrawable.setCallback(this);
    }

    mDesaturateOnPress = a.getBoolean(styleable.BezelImageView_desaturateOnPress, mDesaturateOnPress);

    a.recycle();

    // Other initialization
    mBlackPaint = new Paint();
    mBlackPaint.setColor(0xffff0000);
    mBlackPaint.setAntiAlias(true);

    mMaskedPaint = new Paint();
    mMaskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    mMaskedPaint.setAntiAlias(true);

    // Always want a cache allocated.
    mCacheBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);

    if (mDesaturateOnPress) {
        // Create a desaturate color filter for pressed state.
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0);
        mDesaturateColorFilter = new ColorMatrixColorFilter(cm);
    }
}

From source file:com.geekandroid.sdk.base.BaseActivity.java

@Override
public boolean onTouch(View v, MotionEvent event) {
    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN://start to touch the view
        if (v.getBackground() != null) {
            /**//from   w w  w . j  a v  a  2  s . com
             * set background is color
             */
            if ((v.getBackground() instanceof ColorDrawable)) {
                v.setTag(((ColorDrawable) v.getBackground()).getColor());
                v.setBackgroundColor(getResources().getColor(android.R.color.darker_gray));
            } else {
                /**
                 *  set background   is drawable if you want change saturationby use variable
                 */
                v.setTag("");
                colorMatrix.setSaturation(saturation);
                colorMatrixColorFilter = new ColorMatrixColorFilter(colorMatrix);
                v.getBackground().setColorFilter(colorMatrixColorFilter);
            }
        }
        /**
         * have not set background
         */
        else {
            v.setBackgroundColor(getResources().getColor(android.R.color.darker_gray));
            v.setTag(null);
        }

        break;
    case MotionEvent.ACTION_UP://when the finger leave the screen
    case MotionEvent.ACTION_CANCEL://cancel the action
        /**
         * retrieve background is color
         */
        if (v.getTag() instanceof Integer) {
            v.setBackgroundColor((Integer) v.getTag());
        } else if (v.getTag() instanceof String) {
            colorMatrix.setSaturation(1);
            colorMatrixColorFilter = new ColorMatrixColorFilter(colorMatrix);
            v.getBackground().setColorFilter(colorMatrixColorFilter);
        } else {
            v.setBackgroundColor(getResources().getColor(android.R.color.transparent));
        }
        v.setTag(null);

        break;
    default:
        break;

    }
    mGestureDetector.onTouchEvent(event);
    return false;
}