Example usage for android.graphics Matrix Matrix

List of usage examples for android.graphics Matrix Matrix

Introduction

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

Prototype

public Matrix(Matrix src) 

Source Link

Document

Create a matrix that is a (deep) copy of src

Usage

From source file:android.support.transition.ChangeTransform.java

private void captureValues(TransitionValues transitionValues) {
    View view = transitionValues.view;
    if (view.getVisibility() == View.GONE) {
        return;/*from w ww . ja  v a  2 s  .  c  o  m*/
    }
    transitionValues.values.put(PROPNAME_PARENT, view.getParent());
    Transforms transforms = new Transforms(view);
    transitionValues.values.put(PROPNAME_TRANSFORMS, transforms);
    Matrix matrix = view.getMatrix();
    if (matrix == null || matrix.isIdentity()) {
        matrix = null;
    } else {
        matrix = new Matrix(matrix);
    }
    transitionValues.values.put(PROPNAME_MATRIX, matrix);
    if (mReparent) {
        Matrix parentMatrix = new Matrix();
        ViewGroup parent = (ViewGroup) view.getParent();
        ViewUtils.transformMatrixToGlobal(parent, parentMatrix);
        parentMatrix.preTranslate(-parent.getScrollX(), -parent.getScrollY());
        transitionValues.values.put(PROPNAME_PARENT_MATRIX, parentMatrix);
        transitionValues.values.put(PROPNAME_INTERMEDIATE_MATRIX, view.getTag(R.id.transition_transform));
        transitionValues.values.put(PROPNAME_INTERMEDIATE_PARENT_MATRIX, view.getTag(R.id.parent_matrix));
    }
}

From source file:com.android.camera.HighlightView.java

public void setup(Matrix m, Rect imageRect, RectF cropRect, boolean circle, boolean maintainAspectRatio) {
    if (circle) {
        maintainAspectRatio = true;//from  ww  w.j  a  v a  2 s .co  m
    }
    mMatrix = new Matrix(m);

    mCropRect = cropRect;
    mImageRect = new RectF(imageRect);
    mMaintainAspectRatio = maintainAspectRatio;
    mCircle = circle;

    mInitialAspectRatio = mCropRect.width() / mCropRect.height();
    mDrawRect = computeLayout();

    mFocusPaint.setARGB(125, 50, 50, 50);
    mNoFocusPaint.setARGB(125, 50, 50, 50);
    mOutlinePaint.setStrokeWidth(3F);
    mOutlinePaint.setStyle(Paint.Style.STROKE);
    mOutlinePaint.setAntiAlias(true);

    mMode = ModifyMode.None;
    init();
}

From source file:android.support.transition.ChangeTransform.java

private void createGhostView(final ViewGroup sceneRoot, TransitionValues startValues,
        TransitionValues endValues) {//from   w  w w  . j a  v  a2 s .c  om
    View view = endValues.view;

    Matrix endMatrix = (Matrix) endValues.values.get(PROPNAME_PARENT_MATRIX);
    Matrix localEndMatrix = new Matrix(endMatrix);
    ViewUtils.transformMatrixToLocal(sceneRoot, localEndMatrix);

    GhostViewImpl ghostView = GhostViewUtils.addGhost(view, sceneRoot, localEndMatrix);
    if (ghostView == null) {
        return;
    }
    // Ask GhostView to actually remove the start view when it starts drawing the animation.
    ghostView.reserveEndViewTransition((ViewGroup) startValues.values.get(PROPNAME_PARENT), startValues.view);

    Transition outerTransition = this;
    while (outerTransition.mParent != null) {
        outerTransition = outerTransition.mParent;
    }

    GhostListener listener = new GhostListener(view, ghostView);
    outerTransition.addListener(listener);

    // We cannot do this for older platforms or it invalidates the view and results in
    // flickering, but the view will still be invisible by actually removing it from the parent.
    if (SUPPORTS_VIEW_REMOVAL_SUPPRESSION) {
        if (startValues.view != endValues.view) {
            ViewUtils.setTransitionAlpha(startValues.view, 0);
        }
        ViewUtils.setTransitionAlpha(view, 1);
    }
}

From source file:cn.jmessage.android.uikit.pickerimage.view.BaseZoomableImageView.java

protected void zoomOut(float rate) {
    if (mBitmap == null) {
        return;//from   w  ww  .j  a  v a 2s.  com
    }

    float width = getWidth();
    float height = getHeight();

    Matrix tmp = new Matrix(mSuppMatrix);
    tmp.postScale(1F / sScaleRate, 1F / sScaleRate, width / 2F, height / 2F);
    if (getScale(tmp) < 1F) {
        mSuppMatrix.setScale(1F, 1F, width / 2F, height / 2F);
    } else {
        mSuppMatrix.postScale(1F / rate, 1F / rate, width / 2F, height / 2F);
    }
    setImageMatrix(getImageViewMatrix());
    center(true, true, false);

}

From source file:com.android.volley.ui.PhotoView.java

/**
 * Gets a bitmap of the cropped region. If cropping is not enabled, returns {@code null}.
 *///  w w w.j a v  a2  s .  c o  m
public Bitmap getCroppedPhoto() {
    if (!mAllowCrop) {
        return null;
    }

    final Bitmap croppedBitmap = Bitmap.createBitmap((int) CROPPED_SIZE, (int) CROPPED_SIZE,
            Bitmap.Config.ARGB_8888);
    final Canvas croppedCanvas = new Canvas(croppedBitmap);

    // scale for the final dimensions
    final int cropWidth = mCropRect.right - mCropRect.left;
    final float scaleWidth = CROPPED_SIZE / cropWidth;
    final float scaleHeight = CROPPED_SIZE / cropWidth;

    // translate to the origin & scale
    final Matrix matrix = new Matrix(mDrawMatrix);
    matrix.postTranslate(-mCropRect.left, -mCropRect.top);
    matrix.postScale(scaleWidth, scaleHeight);

    // draw the photo
    if (mDrawable != null) {
        croppedCanvas.concat(matrix);
        mDrawable.draw(croppedCanvas);
    }
    return croppedBitmap;
}

From source file:cl.monsoon.s1next.widget.PhotoView.java

/**
 * Gets a bitmap of the cropped region. If cropping is not enabled, returns {@code null}.
 *//*from ww w  .  j a va  2s.c  o  m*/
public Bitmap getCroppedPhoto() {
    if (!mAllowCrop) {
        return null;
    }

    final Bitmap croppedBitmap = Bitmap.createBitmap((int) CROPPED_SIZE, (int) CROPPED_SIZE,
            Bitmap.Config.ARGB_8888);
    final Canvas croppedCanvas = new Canvas(croppedBitmap);

    // scale for the final dimensions
    final int cropWidth = mCropRect.right - mCropRect.left;
    final float scaleWidth = CROPPED_SIZE / cropWidth;
    final float scaleHeight = CROPPED_SIZE / cropWidth;

    // translate to the origin & scale
    final Matrix matrix = new Matrix(mDrawMatrix);
    matrix.postTranslate(-mCropRect.left, -mCropRect.top);
    matrix.postScale(scaleWidth, scaleHeight);

    // draw the photo
    if (mDrawable != null) {
        croppedCanvas.concat(matrix);
        mDrawable.draw(croppedCanvas);
    }

    return croppedBitmap;
}

From source file:cn.golden.pinchzoomcanvasview.PinchZoomCanvasViewAttacher.java

@Override
public Matrix getDisplayMatrix() {
    return new Matrix(getDrawMatrix());
}

From source file:baizhuan.hangzhou.com.gankcopy.view.customview.photoview.PhotoViewAttacher.java

/**
 * Use {@link #getDisplayMatrix(Matrix)}
 */
@Deprecated
@Override
public Matrix getDisplayMatrix() {
    return new Matrix(getDrawMatrix());
}