Example usage for android.graphics ColorMatrix setConcat

List of usage examples for android.graphics ColorMatrix setConcat

Introduction

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

Prototype

public void setConcat(ColorMatrix matA, ColorMatrix matB) 

Source Link

Document

Set this colormatrix to the concatenation of the two specified colormatrices, such that the resulting colormatrix has the same effect as applying matB and then applying matA.

Usage

From source file:Main.java

public static Bitmap toSepia(Bitmap bmpOriginal) {
    int width, height;
    height = bmpOriginal.getHeight();/*from   ww w.j av a  2  s. c  om*/
    width = bmpOriginal.getWidth();

    Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
    Canvas c = new Canvas(bmpGrayscale);
    Paint paint = new Paint();

    ColorMatrix grMatrix = new ColorMatrix();
    grMatrix.setSaturation(0);

    ColorMatrix scMatrix = new ColorMatrix();
    scMatrix.setScale(1f, .85f, .72f, 1.0f);
    grMatrix.setConcat(scMatrix, grMatrix);

    ColorMatrixColorFilter f = new ColorMatrixColorFilter(grMatrix);
    paint.setColorFilter(f);
    c.drawBitmap(bmpOriginal, 0, 0, paint);
    return bmpGrayscale;
}

From source file:com.bar.foldinglayout.sample.FoldingLayoutActivity.java

@SuppressLint("NewApi")
@Override//from   www  .j  av  a2s  .  co m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_fold);

    mImageView = (ImageView) findViewById(R.id.image_view);
    mImageView.setPadding(ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING);
    mImageView.setScaleType(ImageView.ScaleType.FIT_XY);
    mImageView.setImageDrawable(getResources().getDrawable(R.drawable.image));

    if (IS_ISC) {
        //mTextureView = new TextureView(this);
        //mTextureView.setSurfaceTextureListener(mSurfaceTextureListener);
    }

    mAnchorSeekBar = (SeekBar) findViewById(R.id.anchor_seek_bar);
    mFoldLayout = (FoldingLayout) findViewById(R.id.fold_view);

    mFoldLayout.setFoldListener(mOnFoldListener);

    mAnchorSeekBar.setOnSeekBarChangeListener(mSeekBarChangeListener);

    mItemSelectedListener = new ItemSelectedListener();

    mDefaultPaint = new Paint();
    mSepiaPaint = new Paint();

    ColorMatrix m1 = new ColorMatrix();
    ColorMatrix m2 = new ColorMatrix();
    m1.setSaturation(0);
    m2.setScale(1f, .95f, .82f, 1.0f);
    m1.setConcat(m2, m1);
    mSepiaPaint.setColorFilter(new ColorMatrixColorFilter(m1));
}

From source file:com.example.android.foldinglayout.FoldingLayoutActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_fold);

    mImageView = (ImageView) findViewById(R.id.image_view);
    mImageView.setPadding(ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING);
    mImageView.setScaleType(ImageView.ScaleType.FIT_XY);
    mImageView.setImageDrawable(getResources().getDrawable(R.drawable.image));

    if (hasApiLevel(Build.VERSION_CODES.ICE_CREAM_SANDWICH)) {
        initTextureView();//from  w ww.j  av a 2  s .  c  o m
    }

    mAnchorSeekBar = (SeekBar) findViewById(R.id.anchor_seek_bar);
    mFoldLayout = (FoldingLayout) findViewById(R.id.fold_view);
    mFoldLayout.setBackgroundColor(Color.BLACK);
    mFoldLayout.setFoldListener(mOnFoldListener);

    mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop();

    mAnchorSeekBar.setOnSeekBarChangeListener(mSeekBarChangeListener);

    mScrollGestureDetector = new GestureDetector(this, new ScrollGestureDetector());
    mItemSelectedListener = new ItemSelectedListener();

    mDefaultPaint = new Paint();
    mSepiaPaint = new Paint();

    ColorMatrix m1 = new ColorMatrix();
    ColorMatrix m2 = new ColorMatrix();
    m1.setSaturation(0);
    m2.setScale(1f, .95f, .82f, 1.0f);
    m1.setConcat(m2, m1);
    mSepiaPaint.setColorFilter(new ColorMatrixColorFilter(m1));
}