当前位置: 首页>>代码示例>>Java>>正文


Java Matrix.isIdentity方法代码示例

本文整理汇总了Java中android.graphics.Matrix.isIdentity方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix.isIdentity方法的具体用法?Java Matrix.isIdentity怎么用?Java Matrix.isIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Matrix的用法示例。


在下文中一共展示了Matrix.isIdentity方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateImageViewMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 *
 * @param imageView
 * @param width
 * @param height
 */
public static final void updateImageViewMatrix(ImageView imageView, float width, float height) {
    Drawable drawable = imageView.getDrawable();
    if(drawable == null) {
        throw new NullPointerException("ImageView drawable is null");
    }
    Matrix matrix = imageView.getImageMatrix();
    if(!matrix.isIdentity()) {
        float[] values = new float[9];
        matrix.getValues(values);

        RectF src = new RectF();
        src.left = 0;
        src.top = 0;
        src.right = width;
        src.bottom = height;

        RectF dst = new RectF();
        dst.left = values[Matrix.MTRANS_X];
        dst.top = values[Matrix.MTRANS_Y];
        dst.right = dst.left + (drawable.getIntrinsicWidth() * values[Matrix.MSCALE_X]);
        dst.bottom = dst.top + (drawable.getIntrinsicHeight() * values[Matrix.MSCALE_Y]);

        matrix.setRectToRect(src, dst, Matrix.ScaleToFit.CENTER);
    }
}
 
开发者ID:martinwithaar,项目名称:PinchToZoom,代码行数:32,代码来源:ImageViewUtils.java

示例2: rotateImageExif

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Rotate and/or flip the image to match the given exif orientation.
 *
 * @param pool            A pool that may or may not contain an image of the necessary
 *                        dimensions.
 * @param inBitmap        The bitmap to rotate/flip.
 * @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(@NonNull BitmapPool pool, @NonNull Bitmap inBitmap,
    int exifOrientation) {
  final Matrix matrix = new Matrix();
  initializeMatrixForRotation(exifOrientation, matrix);
  if (matrix.isIdentity()) {
    return inBitmap;
  }

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

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

  Bitmap.Config config = getSafeConfig(inBitmap);
  Bitmap result = pool.get(newWidth, newHeight, config);

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

  applyMatrix(inBitmap, result, matrix);
  return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:TransformationUtils.java

示例3: isTransformedTouchPointInView

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Returns whether the touch point is within the child View
 * It is transform aware and will invert the transform Matrix to find the true local points
 * This code is taken from {@link ViewGroup#isTransformedTouchPointInView()}
 */
private static boolean isTransformedTouchPointInView(
    float x,
    float y,
    ViewGroup parent,
    View child,
    PointF outLocalPoint) {
  float localX = x + parent.getScrollX() - child.getLeft();
  float localY = y + parent.getScrollY() - child.getTop();
  Matrix matrix = child.getMatrix();
  if (!matrix.isIdentity()) {
    float[] localXY = mMatrixTransformCoords;
    localXY[0] = localX;
    localXY[1] = localY;
    Matrix inverseMatrix = mInverseMatrix;
    matrix.invert(inverseMatrix);
    inverseMatrix.mapPoints(localXY);
    localX = localXY[0];
    localY = localXY[1];
  }
  if (child instanceof ReactHitSlopView && ((ReactHitSlopView) child).getHitSlopRect() != null) {
    Rect hitSlopRect = ((ReactHitSlopView) child).getHitSlopRect();
    if ((localX >= -hitSlopRect.left && localX < (child.getRight() - child.getLeft()) + hitSlopRect.right)
        && (localY >= -hitSlopRect.top && localY < (child.getBottom() - child.getTop()) + hitSlopRect.bottom)) {
      outLocalPoint.set(localX, localY);
      return true;
    }

    return false;
  } else {
    if ((localX >= 0 && localX < (child.getRight() - child.getLeft()))
        && (localY >= 0 && localY < (child.getBottom() - child.getTop()))) {
      outLocalPoint.set(localX, localY);
      return true;
    }

    return false;
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:44,代码来源:TouchTargetHelper.java

示例4: setImageMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
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();
	}
}
 
开发者ID:lpy19930103,项目名称:MinimalismJotter,代码行数:12,代码来源:ZoomableImageView.java

示例5: setImageMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
@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();
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:16,代码来源:ImageViewTouchBase.java

示例6: setImageMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
@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();
}
 
开发者ID:viseator,项目名称:MontageCam,代码行数:15,代码来源:ImageViewTouchBase.java

示例7: setImageMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
@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();
    }
}
 
开发者ID:StickyTolt,项目名称:ForeverLibrary,代码行数:15,代码来源:ImageViewTouchBase.java


注:本文中的android.graphics.Matrix.isIdentity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。