本文整理了Java中android.graphics.Matrix.mapRect()
方法的一些代码示例,展示了Matrix.mapRect()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.mapRect()
方法的具体详情如下:
包路径:android.graphics.Matrix
类名称:Matrix
方法名:mapRect
暂无
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Transform a rectangle with all matrices with potential animation phases.
*
* @param r
*/
public void rectValueToPixelHorizontal(RectF r) {
mMatrixValueToPx.mapRect(r);
mViewPortHandler.getMatrixTouch().mapRect(r);
mMatrixOffset.mapRect(r);
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Transform a rectangle with all matrices.
*
* @param r
*/
public void rectValueToPixel(RectF r) {
mMatrixValueToPx.mapRect(r);
mViewPortHandler.getMatrixTouch().mapRect(r);
mMatrixOffset.mapRect(r);
}
代码示例来源:origin: PhilJay/MPAndroidChart
public void rectToPixelPhaseHorizontal(RectF r, float phaseY) {
// multiply the height of the rect with the phase
r.left *= phaseY;
r.right *= phaseY;
mMatrixValueToPx.mapRect(r);
mViewPortHandler.getMatrixTouch().mapRect(r);
mMatrixOffset.mapRect(r);
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Transform a rectangle with all matrices with potential animation phases.
*
* @param r
* @param phaseY
*/
public void rectToPixelPhase(RectF r, float phaseY) {
// multiply the height of the rect with the phase
r.top *= phaseY;
r.bottom *= phaseY;
mMatrixValueToPx.mapRect(r);
mViewPortHandler.getMatrixTouch().mapRect(r);
mMatrixOffset.mapRect(r);
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Transform a rectangle with all matrices with potential animation phases.
*
* @param r
* @param phaseY
*/
public void rectValueToPixelHorizontal(RectF r, float phaseY) {
// multiply the height of the rect with the phase
r.left *= phaseY;
r.right *= phaseY;
mMatrixValueToPx.mapRect(r);
mViewPortHandler.getMatrixTouch().mapRect(r);
mMatrixOffset.mapRect(r);
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* transforms multiple rects with all matrices
*
* @param rects
*/
public void rectValuesToPixel(List<RectF> rects) {
Matrix m = getValueToPixelMatrix();
for (int i = 0; i < rects.size(); i++)
m.mapRect(rects.get(i));
}
代码示例来源:origin: igreenwood/SimpleCropView
private RectF calcImageRect(RectF rect, Matrix matrix) {
RectF applied = new RectF();
matrix.mapRect(applied, rect);
return applied;
}
代码示例来源:origin: chrisbanes/PhotoView
/**
* Helper method that maps the supplied Matrix to the current Drawable
*
* @param matrix - Matrix to map Drawable against
* @return RectF - Displayed Rectangle
*/
private RectF getDisplayRect(Matrix matrix) {
Drawable d = mImageView.getDrawable();
if (d != null) {
mDisplayRect.set(0, 0, d.getIntrinsicWidth(),
d.getIntrinsicHeight());
matrix.mapRect(mDisplayRect);
return mDisplayRect;
}
return null;
}
代码示例来源:origin: jdamcd/android-crop
private Rect computeLayout() {
RectF r = new RectF(cropRect.left, cropRect.top,
cropRect.right, cropRect.bottom);
matrix.mapRect(r);
return new Rect(Math.round(r.left), Math.round(r.top),
Math.round(r.right), Math.round(r.bottom));
}
代码示例来源:origin: airbnb/lottie-android
@Override public void getBounds(RectF outBounds, Matrix parentMatrix, boolean applyParents) {
super.getBounds(outBounds, parentMatrix, applyParents);
rect.set(0, 0, layerModel.getSolidWidth(), layerModel.getSolidHeight());
boundsMatrix.mapRect(rect);
outBounds.set(rect);
}
代码示例来源:origin: sephiroth74/ImageViewZoom
protected RectF getBitmapRect(Matrix supportMatrix) {
Matrix m = getImageViewMatrix(supportMatrix);
m.mapRect(mBitmapRectTmp, mBitmapRect);
return mBitmapRectTmp;
}
代码示例来源:origin: airbnb/lottie-android
@Override public void getBounds(RectF outBounds, Matrix parentMatrix, boolean applyParents) {
super.getBounds(outBounds, parentMatrix, applyParents);
Bitmap bitmap = getBitmap();
if (bitmap != null) {
outBounds.set(0, 0, bitmap.getWidth() * Utils.dpScale(), bitmap.getHeight() * Utils.dpScale());
boundsMatrix.mapRect(outBounds);
}
}
代码示例来源:origin: jeasonlzy/ImagePicker
/**
* @return 获取当前图片显示的矩形区域
*/
private RectF getImageMatrixRect() {
RectF rectF = new RectF();
rectF.set(0, 0, getDrawable().getIntrinsicWidth(), getDrawable().getIntrinsicHeight());
matrix.mapRect(rectF);
return rectF;
}
代码示例来源:origin: bm-x/PhotoView
private void executeTranslate() {
mSynthesisMatrix.set(mBaseMatrix);
mSynthesisMatrix.postConcat(mAnimaMatrix);
setImageMatrix(mSynthesisMatrix);
mAnimaMatrix.mapRect(mImgRect, mBaseRect);
imgLargeWidth = mImgRect.width() > mWidgetRect.width();
imgLargeHeight = mImgRect.height() > mWidgetRect.height();
}
代码示例来源:origin: Hitomis/transferee
private void executeTranslate() {
mSynthesisMatrix.set(mBaseMatrix);
mSynthesisMatrix.postConcat(mAnimaMatrix);
setImageMatrix(mSynthesisMatrix);
mAnimaMatrix.mapRect(mImgRect, mBaseRect);
imgLargeWidth = mImgRect.width() > mWidgetRect.width();
imgLargeHeight = mImgRect.height() > mWidgetRect.height();
}
代码示例来源:origin: steelkiwi/cropiwa
private void updateImageBounds() {
realImageBounds.set(0, 0, getRealImageWidth(), getRealImageHeight());
imageBounds.set(realImageBounds);
imageMatrix.mapRect(imageBounds);
}
代码示例来源:origin: airbnb/lottie-android
@Override void drawLayer(Canvas canvas, Matrix parentMatrix, int parentAlpha) {
L.beginSection("CompositionLayer#draw");
canvas.save();
newClipRect.set(0, 0, layerModel.getPreCompWidth(), layerModel.getPreCompHeight());
parentMatrix.mapRect(newClipRect);
for (int i = layers.size() - 1; i >= 0 ; i--) {
boolean nonEmptyClip = true;
if (!newClipRect.isEmpty()) {
nonEmptyClip = canvas.clipRect(newClipRect);
}
if (nonEmptyClip) {
BaseLayer layer = layers.get(i);
layer.draw(canvas, parentMatrix, parentAlpha);
}
}
canvas.restore();
L.endSection("CompositionLayer#draw");
}
代码示例来源:origin: google/ExoPlayer
/** Applies a texture rotation to a {@link TextureView}. */
private static void applyTextureViewRotation(TextureView textureView, int textureViewRotation) {
float textureViewWidth = textureView.getWidth();
float textureViewHeight = textureView.getHeight();
if (textureViewWidth == 0 || textureViewHeight == 0 || textureViewRotation == 0) {
textureView.setTransform(null);
} else {
Matrix transformMatrix = new Matrix();
float pivotX = textureViewWidth / 2;
float pivotY = textureViewHeight / 2;
transformMatrix.postRotate(textureViewRotation, pivotX, pivotY);
// After rotation, scale the rotated texture to fit the TextureView size.
RectF originalTextureRect = new RectF(0, 0, textureViewWidth, textureViewHeight);
RectF rotatedTextureRect = new RectF();
transformMatrix.mapRect(rotatedTextureRect, originalTextureRect);
transformMatrix.postScale(
textureViewWidth / rotatedTextureRect.width(),
textureViewHeight / rotatedTextureRect.height(),
pivotX,
pivotY);
textureView.setTransform(transformMatrix);
}
}
代码示例来源:origin: bumptech/glide
/**
* 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) {
if (!isExifOrientationRequired(exifOrientation)) {
return inBitmap;
}
final Matrix matrix = new Matrix();
initializeMatrixForRotation(exifOrientation, matrix);
// 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 = getNonNullConfig(inBitmap);
Bitmap result = pool.get(newWidth, newHeight, config);
matrix.postTranslate(-newRect.left, -newRect.top);
result.setHasAlpha(inBitmap.hasAlpha());
applyMatrix(inBitmap, result, matrix);
return result;
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testMapRect() {
final Matrix matrix = new Matrix();
matrix.postScale(2.0f, 3.0f);
final RectF input = new RectF(1.0f, 1.0f, 2.0f, 2.0f);
final RectF output1 = new RectF();
matrix.mapRect(output1, input);
assertThat(output1)
.isEqualTo(new RectF(2.0f, 3.0f, 4.0f, 6.0f));
matrix.postScale(-1.0f, -1.0f);
final RectF output2 = new RectF();
matrix.mapRect(output2, input);
assertThat(output2)
.isEqualTo(new RectF(-4.0f, -6.0f, -2.0f, -3.0f));
}
内容来源于网络,如有侵权,请联系作者删除!