Java Code Examples for android.graphics.Matrix.setConcat()

The following are Jave code examples for showing how to use setConcat() of the android.graphics.Matrix class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: CSipSimple   File: MaxScaleImageView.java   Source Code and License Vote up 5 votes
private void updateScale() {
    Drawable d = getDrawable();
    if(d instanceof BitmapDrawable) {
        BitmapDrawable bd = (BitmapDrawable) d;

        // Don't upscale if more than 2x larger
        if (getWidth() > mMaxScale * bd.getIntrinsicWidth()
                && getHeight() > mMaxScale * bd.getIntrinsicHeight()) {
            setScaleType(ScaleType.MATRIX);
            Matrix trans = new Matrix();
            Matrix scale = new Matrix();
            trans.setTranslate((getWidth() - mMaxScale * bd.getIntrinsicWidth())/2, (getHeight() - mMaxScale * bd.getIntrinsicHeight())/2);
            scale.setScale(mMaxScale, mMaxScale);
            Matrix m = new Matrix();
            
            if(isInEditMode()) {
                // WTF? Edit mode consider inversed matrix??
                m.setConcat(scale, trans);
            }else {
                m.setConcat(trans, scale);
            }
            setImageMatrix(m);
        }else {
            setScaleType(ScaleType.CENTER_CROP);
        }
    }
}