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


Java Matrix.mapRect方法代码示例

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


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

示例1: getDisplayRect

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * 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) {
    ImageView imageView = getImageView();

    if (null != imageView) {
        Drawable d = imageView.getDrawable();
        if (null != d) {
            mDisplayRect.set(0, 0, d.getIntrinsicWidth(),
                    d.getIntrinsicHeight());
            matrix.mapRect(mDisplayRect);
            return mDisplayRect;
        }
    }
    return null;
}
 
开发者ID:snowwolf10285,项目名称:PicShow-zhaipin,代码行数:21,代码来源:PhotoViewAttacher.java

示例2: doInBackground

import android.graphics.Matrix; //导入方法依赖的package包/类
@SuppressWarnings("WrongThread")
   @Override
   protected Bitmap doInBackground(Bitmap... params) {
       RectF cropRect = mCropPanel.getCropRect();// 剪切区域矩形
       Matrix touchMatrix = activity.mainImage.getImageViewMatrix();
       // Canvas canvas = new Canvas(resultBit);
       float[] data = new float[9];
       touchMatrix.getValues(data);// 底部图片变化记录矩阵原始数据
       Matrix3 cal = new Matrix3(data);// 辅助矩阵计算类
       Matrix3 inverseMatrix = cal.inverseMatrix();// 计算逆矩阵
       Matrix m = new Matrix();
       m.setValues(inverseMatrix.getValues());
       m.mapRect(cropRect);// 变化剪切矩形

       // Paint paint = new Paint();
       // paint.setColor(Color.RED);
       // paint.setStrokeWidth(10);
       // canvas.drawRect(cropRect, paint);
       // Bitmap resultBit = Bitmap.createBitmap(params[0]).copy(
       // Bitmap.Config.ARGB_8888, true);
       Bitmap resultBit = Bitmap.createBitmap(params[0], (int) cropRect.left, (int) cropRect
.top, (int) cropRect.width(), (int) cropRect.height());

       //saveBitmap(resultBit, activity.saveFilePath);
       return resultBit;
   }
 
开发者ID:viseator,项目名称:MontageCam,代码行数:27,代码来源:CropFragment.java

示例3: limitTranslation

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Limits the translation so that there are no empty spaces on the sides if possible.
 * <p>
 * <p> The image is attempted to be centered within the view bounds if the transformed image is
 * smaller. There will be no empty spaces within the view bounds if the transformed image is
 * bigger. This applies to each dimension (horizontal and vertical) independently.
 *
 * @param limitTypes whether to limit translation along the specific axis.
 * @return whether limiting has been applied or not
 */
private boolean limitTranslation(Matrix transform, @LimitFlag int limitTypes) {
    if (!shouldLimit(limitTypes, LIMIT_TRANSLATION_X | LIMIT_TRANSLATION_Y)) {
        return false;
    }
    RectF b = mTempRect;
    b.set(mImageBounds);
    transform.mapRect(b);
    float offsetLeft = shouldLimit(limitTypes, LIMIT_TRANSLATION_X) ?
            getOffset(b.left, b.right, mViewBounds.left, mViewBounds.right, mImageBounds.centerX()) : 0;
    float offsetTop = shouldLimit(limitTypes, LIMIT_TRANSLATION_Y) ?
            getOffset(b.top, b.bottom, mViewBounds.top, mViewBounds.bottom, mImageBounds.centerY()) : 0;
    if (offsetLeft != 0 || offsetTop != 0) {
        transform.postTranslate(offsetLeft, offsetTop);
        return true;
    }
    return false;
}
 
开发者ID:ibosong,项目名称:CommentGallery,代码行数:28,代码来源:DefaultZoomableController.java

示例4: limitTranslation

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Limits the translation so that there are no empty spaces on the sides if possible.
 *
 * <p> The image is attempted to be centered within the view bounds if the transformed image is
 * smaller. There will be no empty spaces within the view bounds if the transformed image is
 * bigger. This applies to each dimension (horizontal and vertical) independently.
 *
 * @param limitTypes whether to limit translation along the specific axis.
 * @return whether limiting has been applied or not
 */
private boolean limitTranslation(Matrix transform, @LimitFlag int limitTypes) {
  if (!shouldLimit(limitTypes, LIMIT_TRANSLATION_X | LIMIT_TRANSLATION_Y)) {
    return false;
  }
  RectF b = mTempRect;
  b.set(mImageBounds);
  transform.mapRect(b);
  float offsetLeft = shouldLimit(limitTypes, LIMIT_TRANSLATION_X) ?
      getOffset(b.left, b.right, mViewBounds.left, mViewBounds.right, mImageBounds.centerX()) : 0;
  float offsetTop = shouldLimit(limitTypes, LIMIT_TRANSLATION_Y) ?
      getOffset(b.top, b.bottom, mViewBounds.top, mViewBounds.bottom, mImageBounds.centerY()) : 0;
  if (offsetLeft != 0 || offsetTop != 0) {
    transform.postTranslate(offsetLeft, offsetTop);
    return true;
  }
  return false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:DefaultZoomableController.java

示例5: getDisplayRect

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * 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) {
	ImageView imageView = getImageView();

	if (null != imageView) {
		Drawable d = imageView.getDrawable();
		if (null != d) {
			mDisplayRect.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
			matrix.mapRect(mDisplayRect);
			return mDisplayRect;
		}
	}
	return null;
}
 
开发者ID:turoDog,项目名称:KTalk,代码行数:21,代码来源:PhotoViewAttacher.java

示例6: updateShaderAndSize

import android.graphics.Matrix; //导入方法依赖的package包/类
private static void updateShaderAndSize(@NonNull ImageView.ScaleType scaleType, int vWidth, int vHeight, ImageDrawable imageDrawable, BitmapShader bitmapShader) {
  Matrix matrix = createShaderMatrix(scaleType, vWidth, vHeight,
                                     imageDrawable.bitmapWidth,
                                     imageDrawable.bitmapHeight);
  int intrinsicWidth = vWidth, intrinsicHeight = vHeight;
  if (scaleType == ImageView.ScaleType.FIT_CENTER) {
    RectF bitmapRect = new RectF(0, 0, imageDrawable.bitmapWidth, imageDrawable.bitmapHeight), contentRect = new RectF();
    matrix.mapRect(contentRect, bitmapRect);
    intrinsicWidth = (int) contentRect.width();
    intrinsicHeight = (int) contentRect.height();
    matrix = createShaderMatrix(scaleType, intrinsicWidth, intrinsicHeight, imageDrawable
        .bitmapWidth, imageDrawable.bitmapHeight);
  }
  imageDrawable.setIntrinsicWidth(intrinsicWidth);
  imageDrawable.setIntrinsicHeight(intrinsicHeight);
  bitmapShader.setLocalMatrix(matrix);
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:18,代码来源:ImageDrawable.java

示例7: center

import android.graphics.Matrix; //导入方法依赖的package包/类
protected void center() {
    final Bitmap bitmap = bitmapDisplayed.getBitmap();
    if (bitmap == null) {
        return;
    }
    Matrix m = getImageViewMatrix();

    RectF rect = new RectF(0, 0, bitmap.getWidth(), bitmap.getHeight());
    m.mapRect(rect);

    float height = rect.height();
    float width  = rect.width();

    float deltaX = 0, deltaY = 0;

    deltaY = centerVertical(rect, height, deltaY);
    deltaX = centerHorizontal(rect, width, deltaX);

    postTranslate(deltaX, deltaY);
    setImageMatrix(getImageViewMatrix());
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:22,代码来源:ImageViewTouchBase.java

示例8: evaluatePageSliceBounds

import android.graphics.Matrix; //导入方法依赖的package包/类
private RectF evaluatePageSliceBounds(RectF localPageSliceBounds, PageTreeNode parent) {
    if (parent == null) {
        return localPageSliceBounds;
    }
    final Matrix matrix = new Matrix();
    matrix.postScale(parent.pageSliceBounds.width(), parent.pageSliceBounds.height());
    matrix.postTranslate(parent.pageSliceBounds.left, parent.pageSliceBounds.top);
    final RectF sliceBounds = new RectF();
    matrix.mapRect(sliceBounds, localPageSliceBounds);
    return sliceBounds;
}
 
开发者ID:lidong1665,项目名称:AndroidPDF,代码行数:12,代码来源:PageTreeNode.java

示例9: getVisiblePages

import android.graphics.Matrix; //导入方法依赖的package包/类
protected void getVisiblePages(int[] range) {
    final int count = getChildCount();
    range[0] = -1;
    range[1] = -1;

    if (count > 0) {
        final int visibleLeft = -getLeft();
        final int visibleRight = visibleLeft + getViewportWidth();
        final Matrix pageShiftMatrix = getPageShiftMatrix();
        int curScreen = 0;

        for (int i = 0; i < count; i++) {
            View currPage = getPageAt(i);

            // Verify if the page bounds are within the visible range.
            sTmpRectF.left = 0;
            sTmpRectF.right = currPage.getMeasuredWidth();
            currPage.getMatrix().mapRect(sTmpRectF);
            sTmpRectF.offset(currPage.getLeft() - getScrollX(), 0);
            pageShiftMatrix.mapRect(sTmpRectF);

            if (sTmpRectF.left > visibleRight || sTmpRectF.right < visibleLeft) {
                if (range[0] == -1) {
                    continue;
                } else {
                    break;
                }
            }
            curScreen = i;
            if (range[0] < 0) {
                range[0] = curScreen;
            }
        }

        range[1] = curScreen;
    } else {
        range[0] = -1;
        range[1] = -1;
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:41,代码来源:PagedView.java

示例10: getDisplayRect

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * 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) {
    ImageView imageView = getImageView();

    if (null != imageView) {
        Drawable d = imageView.getDrawable();
        if (null != d) {
            mDisplayRect.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
            matrix.mapRect(mDisplayRect);
            return mDisplayRect;
        }
    }
    return null;
}
 
开发者ID:liuke2016,项目名称:filepicker,代码行数:20,代码来源:PhotoViewAttacher.java

示例11: transform

import android.graphics.Matrix; //导入方法依赖的package包/类
private static RectF transform(Rect rect, int width, int height){
    Matrix mMatrix = new Matrix();
    RectF mRect = new RectF();
    boolean isMirror = false;
    //int Id = CameraInterface.getInstance().getCameraId();
    //if(Id == Camera.CameraInfo.CAMERA_FACING_BACK)isMirror = false;
    //else if(Id == Camera.CameraInfo.CAMERA_FACING_FRONT)isMirror = true;
    Util.prepareMatrix(mMatrix, isMirror, 0, width, height);
    mRect.set(rect);
    mMatrix.mapRect(mRect);

    return mRect;
}
 
开发者ID:MarukoZ,项目名称:FaceRecognition,代码行数:14,代码来源:FaceUtil.java

示例12: getDisplayRect

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:17,代码来源:PhotoViewAttacher.java

示例13: initOverlayParams

import android.graphics.Matrix; //导入方法依赖的package包/类
private boolean initOverlayParams(Matrix matrix) {
  if (overlayParams == null || pageBounds == null) {
    return false;
  }

  // Overlay params previously initiated; skip
  if (overlayParams.init) {
    return true;
  }

  int overlayColor = overlayTextColor;
  if (isNightMode) {
    overlayColor = Color.rgb(nightModeTextBrightness,
        nightModeTextBrightness, nightModeTextBrightness);
  }
  overlayParams.paint.setColor(overlayColor);

  // Use font metrics to calculate the maximum possible height of the text
  FontMetrics fm = overlayParams.paint.getFontMetrics();

  final RectF mappedRect = new RectF();
  matrix.mapRect(mappedRect, pageBounds);

  // Calculate where the text's baseline should be
  // (for top text and bottom text)
  // (p.s. parts of the glyphs will be below the baseline such as a
  // 'y' or 'ي')
  overlayParams.topBaseline = -fm.top;
  overlayParams.bottomBaseline = getHeight() - fm.bottom;

  // Calculate the horizontal margins off the edge of screen
  overlayParams.offsetX = Math.min(
      mappedRect.left, getWidth() - mappedRect.right);

  overlayParams.init = true;
  return true;
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:38,代码来源:HighlightingImageView.java

示例14: doubleTap

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * 双击后放大或者缩小
 *
 * 将图片缩放比例缩放到nextScale指定的值.
 * 但nextScale值不能大于最大缩放值不能小于fit center情况下的缩放值.
 * 将双击的点尽量移动到控件中心.
 *
 * @param x 双击的点
 * @param y 双击的点
 *
 * @see #calculateNextScale(float, float)
 * @see #getMaxScale()
 */
private void doubleTap(float x, float y) {
    if (!isReady()) {
        return;
    }
    //获取第一层变换矩阵
    Matrix innerMatrix = MathUtils.matrixTake();
    getInnerMatrix(innerMatrix);
    //当前总的缩放比例
    float innerScale = MathUtils.getMatrixScale(innerMatrix)[0];
    float outerScale = MathUtils.getMatrixScale(mOuterMatrix)[0];
    float currentScale = innerScale * outerScale;
    //控件大小
    float displayWidth = getWidth();
    float displayHeight = getHeight();
    //最大放大大小
    float maxScale = getMaxScale();
    //接下来要放大的大小
    float nextScale = calculateNextScale(innerScale, outerScale);
    //如果接下来放大大于最大值或者小于fit center值,则取边界
    if (nextScale > maxScale) {
        nextScale = maxScale;
    }
    if (nextScale < innerScale) {
        nextScale = innerScale;
    }
    //开始计算缩放动画的结果矩阵
    Matrix animEnd = MathUtils.matrixTake(mOuterMatrix);
    //计算还需缩放的倍数
    animEnd.postScale(nextScale / currentScale, nextScale / currentScale, x, y);
    //将放大点移动到控件中心
    animEnd.postTranslate(displayWidth / 2f - x, displayHeight / 2f - y);
    //得到放大之后的图片方框
    Matrix testMatrix = MathUtils.matrixTake(innerMatrix);
    testMatrix.postConcat(animEnd);
    RectF testBound = MathUtils.rectFTake(0, 0, getDrawable().getIntrinsicWidth(), getDrawable().getIntrinsicHeight());
    testMatrix.mapRect(testBound);
    //修正位置
    float postX = 0;
    float postY = 0;
    if (testBound.right - testBound.left < displayWidth) {
        postX = displayWidth / 2f - (testBound.right + testBound.left) / 2f;
    } else if (testBound.left > 0) {
        postX = -testBound.left;
    } else if (testBound.right < displayWidth) {
        postX = displayWidth - testBound.right;
    }
    if (testBound.bottom - testBound.top < displayHeight) {
        postY = displayHeight / 2f - (testBound.bottom + testBound.top) / 2f;
    } else if (testBound.top > 0) {
        postY = -testBound.top;
    } else if (testBound.bottom < displayHeight) {
        postY = displayHeight - testBound.bottom;
    }
    //应用修正位置
    animEnd.postTranslate(postX, postY);
    //清理当前可能正在执行的动画
    cancelAllAnimator();
    //启动矩阵动画
    mScaleAnimator = new ScaleAnimator(mOuterMatrix, animEnd);
    mScaleAnimator.start();
    //清理临时变量
    MathUtils.rectFGiven(testBound);
    MathUtils.matrixGiven(testMatrix);
    MathUtils.matrixGiven(animEnd);
    MathUtils.matrixGiven(innerMatrix);
}
 
开发者ID:wendyltan,项目名称:EasyTodo,代码行数:80,代码来源:PinchImageView.java

示例15: processResults

import android.graphics.Matrix; //导入方法依赖的package包/类
private void processResults(
    final long timestamp, final List<Recognition> results, final byte[] originalFrame) {
  final List<Pair<Float, Recognition>> rectsToTrack = new LinkedList<Pair<Float, Recognition>>();

  screenRects.clear();
  final Matrix rgbFrameToScreen = new Matrix(getFrameToCanvasMatrix());

  for (final Recognition result : results) {
    if (result.getLocation() == null) {
      continue;
    }
    final RectF detectionFrameRect = new RectF(result.getLocation());

    final RectF detectionScreenRect = new RectF();
    rgbFrameToScreen.mapRect(detectionScreenRect, detectionFrameRect);

    logger.v(
        "Result! Frame: " + result.getLocation() + " mapped to screen:" + detectionScreenRect);

    screenRects.add(new Pair<Float, RectF>(result.getConfidence(), detectionScreenRect));

    if (detectionFrameRect.width() < MIN_SIZE || detectionFrameRect.height() < MIN_SIZE) {
      logger.w("Degenerate rectangle! " + detectionFrameRect);
      continue;
    }

    rectsToTrack.add(new Pair<Float, Recognition>(result.getConfidence(), result));
  }

  if (rectsToTrack.isEmpty()) {
    logger.v("Nothing to track, aborting.");
    return;
  }

  if (objectTracker == null) {
    logger.w("No ObjectTracker, can't track anything!");
    return;
  }

  logger.i("%d rects to track", rectsToTrack.size());
  for (final Pair<Float, Recognition> potential : rectsToTrack) {
    handleDetection(originalFrame, timestamp, potential);
  }
}
 
开发者ID:apacha,项目名称:TensorflowAndroidDemo,代码行数:45,代码来源:MultiBoxTracker.java


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