Search in sources :

Example 41 with Matrix

use of android.graphics.Matrix in project android_frameworks_base by ResurrectionRemix.

the class View method getMatrix.

/**
     * The transform matrix of this view, which is calculated based on the current
     * rotation, scale, and pivot properties.
     *
     * @see #getRotation()
     * @see #getScaleX()
     * @see #getScaleY()
     * @see #getPivotX()
     * @see #getPivotY()
     * @return The current transform matrix for the view
     */
public Matrix getMatrix() {
    ensureTransformationInfo();
    final Matrix matrix = mTransformationInfo.mMatrix;
    mRenderNode.getMatrix(matrix);
    return matrix;
}
Also used : Matrix(android.graphics.Matrix)

Example 42 with Matrix

use of android.graphics.Matrix in project android_frameworks_base by ResurrectionRemix.

the class View method toGlobalMotionEvent.

/**
     * Transforms a motion event from view-local coordinates to on-screen
     * coordinates.
     *
     * @param ev the view-local motion event
     * @return false if the transformation could not be applied
     * @hide
     */
public boolean toGlobalMotionEvent(MotionEvent ev) {
    final AttachInfo info = mAttachInfo;
    if (info == null) {
        return false;
    }
    final Matrix m = info.mTmpMatrix;
    m.set(Matrix.IDENTITY_MATRIX);
    transformMatrixToGlobal(m);
    ev.transform(m);
    return true;
}
Also used : Matrix(android.graphics.Matrix)

Example 43 with Matrix

use of android.graphics.Matrix in project android_frameworks_base by ResurrectionRemix.

the class AppIconLoader method getResizedBitmap.

/**
     * Resize the app icon to the size we need to save space in our LRU cache.
     * Normal we could assume that all app icons have the same default AOSP defined size.
     * The reality shows that a lot apps do not care about and add just one big icon for
     * all screen resolution.
     */
private static Drawable getResizedBitmap(Drawable source, Context context, float scaleFactor) {
    if (source == null) {
        return null;
    }
    final int iconSize = (int) (context.getResources().getDimensionPixelSize(R.dimen.recent_app_icon_size) * scaleFactor);
    final Bitmap bitmap = ImageHelper.drawableToBitmap(source);
    final Bitmap scaledBitmap = Bitmap.createBitmap(iconSize, iconSize, Config.ARGB_8888);
    final float ratioX = iconSize / (float) bitmap.getWidth();
    final float ratioY = iconSize / (float) bitmap.getHeight();
    final float middleX = iconSize / 2.0f;
    final float middleY = iconSize / 2.0f;
    final Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
    paint.setAntiAlias(true);
    final Matrix scaleMatrix = new Matrix();
    scaleMatrix.setScale(ratioX, ratioY, middleX, middleY);
    final Canvas canvas = new Canvas(scaledBitmap);
    canvas.setMatrix(scaleMatrix);
    canvas.drawBitmap(bitmap, middleX - bitmap.getWidth() / 2, middleY - bitmap.getHeight() / 2, paint);
    return new BitmapDrawable(context.getResources(), scaledBitmap);
}
Also used : Bitmap(android.graphics.Bitmap) Matrix(android.graphics.Matrix) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Paint(android.graphics.Paint)

Example 44 with Matrix

use of android.graphics.Matrix in project android_frameworks_base by ResurrectionRemix.

the class ActivityTransitionCoordinator method setSharedElementState.

protected ArrayList<SharedElementOriginalState> setSharedElementState(Bundle sharedElementState, final ArrayList<View> snapshots) {
    ArrayList<SharedElementOriginalState> originalImageState = new ArrayList<SharedElementOriginalState>();
    if (sharedElementState != null) {
        Matrix tempMatrix = new Matrix();
        RectF tempRect = new RectF();
        final int numSharedElements = mSharedElements.size();
        for (int i = 0; i < numSharedElements; i++) {
            View sharedElement = mSharedElements.get(i);
            String name = mSharedElementNames.get(i);
            SharedElementOriginalState originalState = getOldSharedElementState(sharedElement, name, sharedElementState);
            originalImageState.add(originalState);
            setSharedElementState(sharedElement, name, sharedElementState, tempMatrix, tempRect, null);
        }
    }
    if (mListener != null) {
        mListener.onSharedElementStart(mSharedElementNames, mSharedElements, snapshots);
    }
    return originalImageState;
}
Also used : RectF(android.graphics.RectF) Matrix(android.graphics.Matrix) ArrayList(java.util.ArrayList) ImageView(android.widget.ImageView) GhostView(android.view.GhostView) View(android.view.View)

Example 45 with Matrix

use of android.graphics.Matrix in project android_frameworks_base by ResurrectionRemix.

the class ActivityTransitionCoordinator method getSharedElementParentMatrix.

private void getSharedElementParentMatrix(View view, Matrix matrix) {
    final int index = mSharedElementParentMatrices == null ? -1 : mSharedElements.indexOf(view);
    if (index < 0) {
        matrix.reset();
        ViewParent viewParent = view.getParent();
        if (viewParent instanceof ViewGroup) {
            // Find the location in the view's parent
            ViewGroup parent = (ViewGroup) viewParent;
            parent.transformMatrixToLocal(matrix);
            matrix.postTranslate(parent.getScrollX(), parent.getScrollY());
        }
    } else {
        // The indices of mSharedElementParentMatrices matches the
        // mSharedElement matrices.
        Matrix parentMatrix = mSharedElementParentMatrices.get(index);
        matrix.set(parentMatrix);
    }
}
Also used : Matrix(android.graphics.Matrix) ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup)

Aggregations

Matrix (android.graphics.Matrix)1590 Bitmap (android.graphics.Bitmap)487 Paint (android.graphics.Paint)344 RectF (android.graphics.RectF)276 Test (org.junit.Test)154 Canvas (android.graphics.Canvas)139 Rect (android.graphics.Rect)127 ColorMatrix (android.graphics.ColorMatrix)87 Point (android.graphics.Point)79 View (android.view.View)78 Path (android.graphics.Path)74 ImageView (android.widget.ImageView)73 ShadowBitmap (org.robolectric.shadows.ShadowBitmap)67 ShadowMatrix (org.robolectric.shadows.ShadowMatrix)67 IOException (java.io.IOException)61 Drawable (android.graphics.drawable.Drawable)48 BitmapFactory (android.graphics.BitmapFactory)47 Bundle (android.os.Bundle)46 ViewGroup (android.view.ViewGroup)44 PointF (android.graphics.PointF)42