android.graphics.Matrix#isIdentity ( )源码实例Demo

下面列出了android.graphics.Matrix#isIdentity ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: deltachat-android   文件: AnimationMatrix.java
static @NonNull AnimationMatrix animate(@NonNull Matrix from, @NonNull Matrix to, @Nullable Runnable invalidate) {
  if (invalidate == null) {
    return NULL;
  }

  Matrix undo = new Matrix();
  boolean inverted = to.invert(undo);
  if (inverted) {
    undo.preConcat(from);
  }
  if (inverted && !undo.isIdentity()) {
    AnimationMatrix animationMatrix = new AnimationMatrix(undo, invalidate);
    animationMatrix.start(interpolator);
    return animationMatrix;
  } else {
    return NULL;
  }
}
 
源代码2 项目: Carbon   文件: Toolbar.java
public void getHitRect(@NonNull Rect outRect) {
    Matrix matrix = getMatrix();
    if (matrix.isIdentity()) {
        outRect.set(getLeft(), getTop(), getRight(), getBottom());
    } else {
        tmpHitRect.set(0, 0, getWidth(), getHeight());
        matrix.mapRect(tmpHitRect);
        outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(),
                (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop());
    }
    outRect.left -= touchMargin.left;
    outRect.top -= touchMargin.top;
    outRect.right += touchMargin.right;
    outRect.bottom += touchMargin.bottom;
}
 
源代码3 项目: mollyim-android   文件: EditorModel.java
@Override
public void onReady(@NonNull Renderer renderer, @Nullable Matrix cropMatrix, @Nullable Point size) {
  if (cropMatrix != null && size != null && isRendererOfMainImage(renderer)) {
    boolean changedBefore   = isChanged();
    Matrix  imageCropMatrix = editorElementHierarchy.getImageCrop().getLocalMatrix();
    this.size.set(size.x, size.y);
    if (imageCropMatrix.isIdentity()) {
      imageCropMatrix.set(cropMatrix);

      if (circleEditing) {
        Matrix userCropMatrix = editorElementHierarchy.getCropEditorElement().getLocalMatrix();
        if (size.x > size.y) {
          userCropMatrix.setScale(size.y / (float) size.x, 1f);
        } else {
          userCropMatrix.setScale(1f, size.x / (float) size.y);
        }
      }

      editorElementHierarchy.doneCrop(visibleViewPort, null);

      if (!changedBefore) {
        undoRedoStacks.clear(editorElementHierarchy.getRoot());
      }

      if (circleEditing) {
        startCrop();
      }
    }
  }
}
 
源代码4 项目: giffun   文件: TransformationUtils.java
/**
 * Rotate and/or flip the image to match the given exif orientation.
 *
 * @param toOrient The bitmap to rotate/flip.
 * @param pool A pool that may or may not contain an image of the necessary dimensions.
 * @param exifOrientation the exif orientation [1-8].
 * @return The rotated and/or flipped image or toOrient if no rotation or flip was necessary.
 */
public static Bitmap rotateImageExif(Bitmap toOrient, BitmapPool pool, int exifOrientation) {
    final Matrix matrix = new Matrix();
    initializeMatrixForRotation(exifOrientation, matrix);
    if (matrix.isIdentity()) {
        return toOrient;
    }

    // From Bitmap.createBitmap.
    final RectF newRect = new RectF(0, 0, toOrient.getWidth(), toOrient.getHeight());
    matrix.mapRect(newRect);

    final int newWidth = Math.round(newRect.width());
    final int newHeight = Math.round(newRect.height());

    Bitmap.Config config = getSafeConfig(toOrient);
    Bitmap result = pool.get(newWidth, newHeight, config);
    if (result == null) {
        result = Bitmap.createBitmap(newWidth, newHeight, config);
    }

    matrix.postTranslate(-newRect.left, -newRect.top);

    final Canvas canvas = new Canvas(result);
    final Paint paint = new Paint(PAINT_FLAGS);
    canvas.drawBitmap(toOrient, matrix, paint);

    return result;
}
 
源代码5 项目: Carbon   文件: MotionLayout.java
public void getHitRect(@NonNull Rect outRect) {
    Matrix matrix = getMatrix();
    if (matrix.isIdentity()) {
        outRect.set(getLeft(), getTop(), getRight(), getBottom());
    } else {
        tmpHitRect.set(0, 0, getWidth(), getHeight());
        matrix.mapRect(tmpHitRect);
        outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(),
                (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop());
    }
    outRect.left -= touchMargin.left;
    outRect.top -= touchMargin.top;
    outRect.right += touchMargin.right;
    outRect.bottom += touchMargin.bottom;
}
 
源代码6 项目: ClipPathLayout   文件: ClipPathLayoutDelegate.java
private void transformPointToViewLocal(float[] point, View child) {
    point[0] += mParent.getScrollX() - child.getLeft();
    point[1] += mParent.getScrollY() - child.getTop();
    Matrix matrix = child.getMatrix();
    if (!matrix.isIdentity()) {
        Matrix invert = getTempMatrix();
        boolean result = matrix.invert(invert);
        if (result) {
            invert.mapPoints(point);
        }
    }
}
 
源代码7 项目: DanDanPlayForAndroid   文件: ImageViewTouchBase.java
@Override
public void setImageMatrix( Matrix matrix ) {

	Matrix current = getImageMatrix();
	boolean needUpdate = false;
	
	if ( matrix == null && !current.isIdentity() || matrix != null && !current.equals( matrix ) ) {
		needUpdate = true;
	}
	
	super.setImageMatrix( matrix );
	
	if ( needUpdate ) onImageMatrixChanged();
}
 
源代码8 项目: Carbon   文件: CoordinatorLayout.java
public void getHitRect(@NonNull Rect outRect) {
    Matrix matrix = getMatrix();
    if (matrix.isIdentity()) {
        outRect.set(getLeft(), getTop(), getRight(), getBottom());
    } else {
        tmpHitRect.set(0, 0, getWidth(), getHeight());
        matrix.mapRect(tmpHitRect);
        outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(),
                (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop());
    }
    outRect.left -= touchMargin.left;
    outRect.top -= touchMargin.top;
    outRect.right += touchMargin.right;
    outRect.bottom += touchMargin.bottom;
}
 
源代码9 项目: Carbon   文件: FlowLayout.java
public void getHitRect(@NonNull Rect outRect) {
    Matrix matrix = getMatrix();
    if (matrix.isIdentity()) {
        outRect.set(getLeft(), getTop(), getRight(), getBottom());
    } else {
        tmpHitRect.set(0, 0, getWidth(), getHeight());
        matrix.mapRect(tmpHitRect);
        outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(),
                (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop());
    }
    outRect.left -= touchMargin.left;
    outRect.top -= touchMargin.top;
    outRect.right += touchMargin.right;
    outRect.bottom += touchMargin.bottom;
}
 
源代码10 项目: SplitImageView   文件: SplitImageView.java
public void setImageMatrix(Matrix matrix) {
    // collaps null and identity to just null
    if (matrix != null && matrix.isIdentity()) {
        matrix = null;
    }

    // don't invalidate unless we're actually changing our matrix
    if (matrix == null && !mMatrix.isIdentity() ||
            matrix != null && !mMatrix.equals(matrix)) {
        mMatrix.set(matrix);
        configureBounds();
        invalidate();
    }
}
 
源代码11 项目: o2oa   文件: BaseZoomableImageView.java
public void setImageMatrix(Matrix m){
	if (m != null && m.isIdentity()) {
		m = null;
	}

	// don't invalidate unless we're actually changing our matrix
	if (m == null && !this.mMatrix.isIdentity() || m != null && !this.mMatrix.equals(m)) {
		this.mMatrix.set(m);
		invalidate();
	}
}
 
源代码12 项目: NIM_Android_UIKit   文件: BaseZoomableImageView.java
public void setImageMatrix(Matrix m) {
    if (m != null && m.isIdentity()) {
        m = null;
    }

    // don't invalidate unless we're actually changing our matrix
    if (m == null && !this.mMatrix.isIdentity() || m != null && !this.mMatrix.equals(m)) {
        this.mMatrix.set(m);
        invalidate();
    }
}
 
源代码13 项目: Carbon   文件: RecyclerView.java
public void getHitRect(@NonNull Rect outRect) {
    Matrix matrix = getMatrix();
    if (matrix.isIdentity()) {
        outRect.set(getLeft(), getTop(), getRight(), getBottom());
    } else {
        tmpHitRect.set(0, 0, getWidth(), getHeight());
        matrix.mapRect(tmpHitRect);
        outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(),
                (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop());
    }
    outRect.left -= touchMargin.left;
    outRect.top -= touchMargin.top;
    outRect.right += touchMargin.right;
    outRect.bottom += touchMargin.bottom;
}
 
源代码14 项目: Carbon   文件: View.java
public void getHitRect(@NonNull Rect outRect) {
    Matrix matrix = getMatrix();
    if (matrix.isIdentity()) {
        outRect.set(getLeft(), getTop(), getRight(), getBottom());
    } else {
        tmpHitRect.set(0, 0, getWidth(), getHeight());
        matrix.mapRect(tmpHitRect);
        outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(),
                (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop());
    }
    outRect.left -= touchMargin.left;
    outRect.top -= touchMargin.top;
    outRect.right += touchMargin.right;
    outRect.bottom += touchMargin.bottom;
}
 
源代码15 项目: Carbon   文件: AppBarLayout.java
public void getHitRect(@NonNull Rect outRect) {
    Matrix matrix = getMatrix();
    if (matrix.isIdentity()) {
        outRect.set(getLeft(), getTop(), getRight(), getBottom());
    } else {
        tmpHitRect.set(0, 0, getWidth(), getHeight());
        matrix.mapRect(tmpHitRect);
        outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(),
                (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop());
    }
    outRect.left -= touchMargin.left;
    outRect.top -= touchMargin.top;
    outRect.right += touchMargin.right;
    outRect.bottom += touchMargin.bottom;
}
 
源代码16 项目: Carbon   文件: CollapsingToolbarLayout.java
public void getHitRect(@NonNull Rect outRect) {
    Matrix matrix = getMatrix();
    if (matrix.isIdentity()) {
        outRect.set(getLeft(), getTop(), getRight(), getBottom());
    } else {
        tmpHitRect.set(0, 0, getWidth(), getHeight());
        matrix.mapRect(tmpHitRect);
        outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(),
                (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop());
    }
    outRect.left -= touchMargin.left;
    outRect.top -= touchMargin.top;
    outRect.right += touchMargin.right;
    outRect.bottom += touchMargin.bottom;
}
 
源代码17 项目: Carbon   文件: TextView.java
public void getHitRect(@NonNull Rect outRect) {
    Matrix matrix = getMatrix();
    if (matrix.isIdentity()) {
        outRect.set(getLeft(), getTop(), getRight(), getBottom());
    } else {
        tmpHitRect.set(0, 0, getWidth(), getHeight());
        matrix.mapRect(tmpHitRect);
        outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(),
                (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop());
    }
    outRect.left -= touchMargin.left;
    outRect.top -= touchMargin.top;
    outRect.right += touchMargin.right;
    outRect.bottom += touchMargin.bottom;
}
 
源代码18 项目: Carbon   文件: RelativeLayout.java
public void getHitRect(@NonNull Rect outRect) {
    Matrix matrix = getMatrix();
    if (matrix.isIdentity()) {
        outRect.set(getLeft(), getTop(), getRight(), getBottom());
    } else {
        tmpHitRect.set(0, 0, getWidth(), getHeight());
        matrix.mapRect(tmpHitRect);
        outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(),
                (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop());
    }
    outRect.left -= touchMargin.left;
    outRect.top -= touchMargin.top;
    outRect.right += touchMargin.right;
    outRect.bottom += touchMargin.bottom;
}
 
源代码19 项目: Carbon   文件: GridLayout.java
public void getHitRect(@NonNull Rect outRect) {
    Matrix matrix = getMatrix();
    if (matrix.isIdentity()) {
        outRect.set(getLeft(), getTop(), getRight(), getBottom());
    } else {
        tmpHitRect.set(0, 0, getWidth(), getHeight());
        matrix.mapRect(tmpHitRect);
        outRect.set((int) tmpHitRect.left + getLeft(), (int) tmpHitRect.top + getTop(),
                (int) tmpHitRect.right + getLeft(), (int) tmpHitRect.bottom + getTop());
    }
    outRect.left -= touchMargin.left;
    outRect.top -= touchMargin.top;
    outRect.right += touchMargin.right;
    outRect.bottom += touchMargin.bottom;
}
 
源代码20 项目: Matisse-Kotlin   文件: BitmapLoadShowTask.java
@Override
@NonNull
protected BitmapWorkerResult doInBackground(Void... params) {
    if (mInputUri == null) {
        return new BitmapWorkerResult(new NullPointerException("Input Uri cannot be null"));
    }

    final ParcelFileDescriptor parcelFileDescriptor;
    try {
        parcelFileDescriptor = mContext.getContentResolver().openFileDescriptor(mInputUri, "r");
    } catch (FileNotFoundException e) {
        return new BitmapWorkerResult(e);
    }

    final FileDescriptor fileDescriptor;
    if (parcelFileDescriptor != null) {
        fileDescriptor = parcelFileDescriptor.getFileDescriptor();
    } else {
        return new BitmapWorkerResult(new NullPointerException("ParcelFileDescriptor was null for given Uri: [" + mInputUri + "]"));
    }

    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);
    if (options.outWidth == -1 || options.outHeight == -1) {
        return new BitmapWorkerResult(new IllegalArgumentException("Bounds for bitmap could not be retrieved from the Uri: [" + mInputUri + "]"));
    }

    options.inSampleSize = BitmapLoadUtils.calculateInSampleSize(options, mRequiredWidth, mRequiredHeight);
    options.inJustDecodeBounds = false;

    Bitmap decodeSampledBitmap = null;

    boolean decodeAttemptSuccess = false;
    while (!decodeAttemptSuccess) {
        try {
            decodeSampledBitmap = BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);
            decodeAttemptSuccess = true;
        } catch (OutOfMemoryError error) {
            Log.e(TAG, "doInBackground: BitmapFactory.decodeFileDescriptor: ", error);
            options.inSampleSize *= 2;
        }
    }

    if (decodeSampledBitmap == null) {
        return new BitmapWorkerResult(new IllegalArgumentException("Bitmap could not be decoded from the Uri: [" + mInputUri + "]"));
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        BitmapLoadUtils.close(parcelFileDescriptor);
    }

    int exifOrientation = BitmapLoadUtils.getExifOrientation(mContext, mInputUri);
    int exifDegrees = BitmapLoadUtils.exifToDegrees(exifOrientation);
    int exifTranslation = BitmapLoadUtils.exifToTranslation(exifOrientation);

    ExifInfo exifInfo = new ExifInfo(exifOrientation, exifDegrees, exifTranslation);

    Matrix matrix = new Matrix();
    if (exifDegrees != 0) {
        matrix.preRotate(exifDegrees);
    }
    if (exifTranslation != 1) {
        matrix.postScale(exifTranslation, 1);
    }
    if (!matrix.isIdentity()) {
        return new BitmapWorkerResult(BitmapLoadUtils.transformBitmap(decodeSampledBitmap, matrix), exifInfo);
    }

    return new BitmapWorkerResult(decodeSampledBitmap, exifInfo);
}