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


Java Matrix.mapPoints方法代码示例

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


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

示例1: calculateTransformedRenderSize

import android.graphics.Matrix; //导入方法依赖的package包/类
private void calculateTransformedRenderSize(
    int frameWidth, int frameHeight, Matrix renderMatrix) {
  if (renderMatrix == null) {
    renderWidth = frameWidth;
    renderHeight = frameHeight;
    return;
  }
  // Transform the texture coordinates (in the range [0, 1]) according to |renderMatrix|.
  renderMatrix.mapPoints(dstPoints, srcPoints);

  // Multiply with the width and height to get the positions in terms of pixels.
  for (int i = 0; i < 3; ++i) {
    dstPoints[i * 2 + 0] *= frameWidth;
    dstPoints[i * 2 + 1] *= frameHeight;
  }

  // Get the length of the sides of the transformed rectangle in terms of pixels.
  renderWidth = distance(dstPoints[0], dstPoints[1], dstPoints[2], dstPoints[3]);
  renderHeight = distance(dstPoints[0], dstPoints[1], dstPoints[4], dstPoints[5]);
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:21,代码来源:VideoFrameDrawer.java

示例2: setManualFocusAt

import android.graphics.Matrix; //导入方法依赖的package包/类
void setManualFocusAt(int x, int y) {
    int mDisplayOrientation = getActivity().getWindowManager().getDefaultDisplay().getRotation();
    float points[] = new float[2];
    points[0] = (float) x / mTextureView.getWidth();
    points[1] = (float) y / mTextureView.getHeight();
    Matrix rotationMatrix = new Matrix();
    rotationMatrix.setRotate(mDisplayOrientation, 0.5f, 0.5f);
    rotationMatrix.mapPoints(points);
    if (mPreviewRequestBuilder != null) {
        mIsManualFocusing = true;
        updateManualFocus(points[0], points[1]);
        if (mPreviewSession != null) {
            try {
                mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
                    CaptureRequest.CONTROL_AF_TRIGGER_START);
                mPreviewSession.capture(mPreviewRequestBuilder.build(), null, mBackgroundHandler);
                mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
                    CaptureRequest.CONTROL_AF_TRIGGER_IDLE);
                mPreviewSession.setRepeatingRequest(mPreviewRequestBuilder.build(),
                    null, mBackgroundHandler);
            } catch (CameraAccessException | IllegalStateException e) {
                Log.e(TAG, "Failed to set manual focus.", e);
            }
        }
        resumeAutoFocusAfterManualFocus();
    }
}
 
开发者ID:lytcom,项目名称:CameraKitView,代码行数:28,代码来源:Camera2Fragment.java

示例3: inverseMatrixPoint

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * 计算点除以矩阵的值
 *
 * matrix.mapPoints(unknownPoint) -> point
 * 已知point和matrix,求unknownPoint的值.
 *
 * @param point
 * @param matrix
 * @return unknownPoint
 */
public static float[] inverseMatrixPoint(float[] point, Matrix matrix) {
    if (point != null && matrix != null) {
        float[] dst = new float[2];
        //计算matrix的逆矩阵
        Matrix inverse = matrixTake();
        matrix.invert(inverse);
        //用逆矩阵变换point到dst,dst就是结果
        inverse.mapPoints(dst, point);
        //清除临时变量
        matrixGiven(inverse);
        return dst;
    } else {
        return new float[2];
    }
}
 
开发者ID:ZhouKanZ,项目名称:SweepRobot,代码行数:26,代码来源:PinchImageView.java

示例4: 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

示例5: getColorFromBitmap

import android.graphics.Matrix; //导入方法依赖的package包/类
private int getColorFromBitmap(float x, float y) {
    if (paletteDrawable == null) return 0;

    Matrix invertMatrix = new Matrix();
    palette.getImageMatrix().invert(invertMatrix);

    float[] mappedPoints = new float[]{x, y};
    invertMatrix.mapPoints(mappedPoints);

    if (palette.getDrawable() != null && palette.getDrawable() instanceof BitmapDrawable &&
            mappedPoints[0] > 0 && mappedPoints[1] > 0 &&
            mappedPoints[0] < palette.getDrawable().getIntrinsicWidth() && mappedPoints[1] < palette.getDrawable().getIntrinsicHeight()) {

        invalidate();
        return ((BitmapDrawable) palette.getDrawable()).getBitmap().getPixel((int) mappedPoints[0], (int) mappedPoints[1]);
    }
    return 0;
}
 
开发者ID:skydoves,项目名称:ColorPickerView,代码行数:19,代码来源:MultiColorPickerView.java

示例6: createThumbnail

import android.graphics.Matrix; //导入方法依赖的package包/类
protected static Bitmap createThumbnail(InputStreamProvider streamProvider, Context context,
                                        int rotation, boolean leftAligned) {
    Point size = getDefaultThumbSize(context.getResources());
    int width = size.x;
    int height = size.y;
    Point bounds = streamProvider.getImageBounds();
    if (bounds == null) {
        return null;
    }

    Matrix rotateMatrix = new Matrix();
    rotateMatrix.setRotate(rotation);
    float[] rotatedBounds = new float[]{bounds.x, bounds.y};
    rotateMatrix.mapPoints(rotatedBounds);
    rotatedBounds[0] = Math.abs(rotatedBounds[0]);
    rotatedBounds[1] = Math.abs(rotatedBounds[1]);

    RectF cropRect = Utils.getMaxCropRect(
            (int) rotatedBounds[0], (int) rotatedBounds[1], width, height, leftAligned);
    return streamProvider.readCroppedBitmap(cropRect, width, height, rotation);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:22,代码来源:WallpaperTileInfo.java

示例7: rotatePoint

import android.graphics.Matrix; //导入方法依赖的package包/类
private Point rotatePoint(Point point, float degrees, float cx, float cy) {
    float[] pts = new float[2];
    pts[0] = point.x;
    pts[1] = point.y;

    Matrix transform = new Matrix();
    transform.setRotate(degrees, cx, cy);
    transform.mapPoints(pts);

    return new Point((int) pts[0], (int) pts[1]);
}
 
开发者ID:team-supercharge,项目名称:ShimmerLayout,代码行数:12,代码来源:ShimmerLayout.java

示例8: setManualFocusAt

import android.graphics.Matrix; //导入方法依赖的package包/类
void setManualFocusAt(int x, int y) {
    int mDisplayOrientation = mWindowManager.getDefaultDisplay().getRotation();
    float points[] = new float[2];
    points[0] = (float) x / mTextureView.getWidth();
    points[1] = (float) y / mTextureView.getHeight();
    Matrix rotationMatrix = new Matrix();
    rotationMatrix.setRotate(mDisplayOrientation, 0.5f, 0.5f);
    rotationMatrix.mapPoints(points);
    if (mPreviewRequestBuilder != null) {
        mIsManualFocusing = true;
        updateManualFocus(points[0], points[1]);
        if (mPreviewSession != null) {
            try {
                mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
                    CaptureRequest.CONTROL_AF_TRIGGER_START);
                mPreviewSession.capture(mPreviewRequestBuilder.build(), null, mBackgroundHandler);
                mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
                    CaptureRequest.CONTROL_AF_TRIGGER_IDLE);
                mPreviewSession.setRepeatingRequest(mPreviewRequestBuilder.build(),
                    null, mBackgroundHandler);
            } catch (CameraAccessException | IllegalStateException e) {
                Log.e(TAG, "Failed to set manual focus.", e);
            }
        }
        resumeAutoFocusAfterManualFocus();
    }
}
 
开发者ID:lytcom,项目名称:CameraKitView,代码行数:28,代码来源:Camera2.java

示例9: changeRelativePoint

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * 基于原点求出相对于图片坐标系的坐标点
 * @param locationX 原点x
 * @param locationY 原点y
 * @param matrix
 * @return
 */
public static PointF changeRelativePoint(float locationX,float locationY, Matrix matrix){

    float[] arrayOfFloat= new float[2];
    arrayOfFloat[0]=locationX;
    arrayOfFloat[1]=locationY;
    Matrix invertMatrix=new Matrix();
    //得到逆矩阵
    matrix.invert(invertMatrix);
    //将此矩阵应用于2D点阵列,并将转换的点写入数组
    invertMatrix.mapPoints(arrayOfFloat);
    float x = arrayOfFloat[0];
    float y = arrayOfFloat[1];
    return new PointF(x,y);
}
 
开发者ID:ZhouKanZ,项目名称:SweepRobot,代码行数:22,代码来源:DegreeManager.java

示例10: calculateBounds

import android.graphics.Matrix; //导入方法依赖的package包/类
public boolean calculateBounds() {

        float[] src = new float[8];
        float[] dst = new float[]{0, 0, getWidth(), 0, 0, getHeight(), getWidth(), getHeight()};
        Matrix matrix = getMatrix();

        matrix.mapPoints(src, dst);
        topLeft.x = src[0] + getLeft();
        topLeft.y = src[1] + getTop();
        topRight.x = src[2] + getLeft();
        topRight.y = src[3] + getTop();

        bottomLeft.x = src[4] + getLeft();
        bottomLeft.y = src[5] + getTop();
        bottomRight.x = src[6] + getLeft();
        bottomRight.y = src[7] + getTop();
        boolean returnValue = hasMatrixChanged(src);
        prevSrc = src;
        float percentFrom90X = (getRotationX()) / 90f;
        float percentFrom90Y = (-getRotationY()) / 90f;


        matrix.postTranslate(percentFrom90Y * getDepth(), percentFrom90X * getDepth());
        src = new float[8];
        dst = new float[]{0, 0, getWidth(), 0, 0, getHeight(), getWidth(), getHeight()};
        matrix.mapPoints(src, dst);

        topLeftBack.x = src[0] + getLeft();
        topLeftBack.y = src[1] + getTop();
        topRightBack.x = src[2] + getLeft();
        topRightBack.y = src[3] + getTop();

        bottomLeftBack.x = src[4] + getLeft();
        bottomLeftBack.y = src[5] + getTop();
        bottomRightBack.x = src[6] + getLeft();
        bottomRightBack.y = src[7] + getTop();
        customShadow.calculateBounds(this);

        return returnValue;
    }
 
开发者ID:florent37,项目名称:Depth,代码行数:41,代码来源:DepthRelativeLayout.java

示例11: getTransformedTileCoordX

import android.graphics.Matrix; //导入方法依赖的package包/类
private int getTransformedTileCoordX(int x) {
	Matrix m = getCoordTransformMatrix();
	float [] p = new float[]{x, 0};
	m.mapPoints(p);
	return (int) p[0];
}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:7,代码来源:TileBoardGameFragmentController.java

示例12: getTransformedTileCoordY

import android.graphics.Matrix; //导入方法依赖的package包/类
private int getTransformedTileCoordY(int y) {
	Matrix m = getCoordTransformMatrix();
	float [] p = new float[]{0, y};
	m.mapPoints(p);
	return (int) p[1];
}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:7,代码来源:TileBoardGameFragmentController.java

示例13: takeScreenshot

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Takes Reboot screenshot of the current display and shows an animation.
 */
@SuppressLint("NewApi")
public void takeScreenshot(Context context, String fileFullPath)
{
    if(fileFullPath == ""){
        format = new SimpleDateFormat("yyyyMMddHHmmss");
        String fileName = format.format(new Date(System.currentTimeMillis())) + ".png";
        fileFullPath = "/data/local/tmp/" + fileName;
    }

    if(ShellUtils.checkRootPermission()){
        if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH){
            ShellUtils.execCommand("/system/bin/screencap -p "+ fileFullPath,true);
        }
    }
    else {
        if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2 && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH){
            wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
            mDisplay = wm.getDefaultDisplay();
            mDisplayMatrix = new Matrix();
            mDisplayMetrics = new DisplayMetrics();
            // We need to orient the screenshot correctly (and the Surface api seems to take screenshots
            // only in the natural orientation of the device :!)
            mDisplay.getRealMetrics(mDisplayMetrics);
            float[] dims =
                    {
                            mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels
                    };
            float degrees = getDegreesForRotation(mDisplay.getRotation());
            boolean requiresRotation = (degrees > 0);
            if (requiresRotation)
            {
                // Get the dimensions of the device in its native orientation
                mDisplayMatrix.reset();
                mDisplayMatrix.preRotate(-degrees);
                mDisplayMatrix.mapPoints(dims);
                dims[0] = Math.abs(dims[0]);
                dims[1] = Math.abs(dims[1]);
            }

            Bitmap mScreenBitmap = screenShot((int) dims[0], (int) dims[1]);
            if (requiresRotation)
            {
                // Rotate the screenshot to the current orientation
                Bitmap ss = Bitmap.createBitmap(mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels,
                        Bitmap.Config.ARGB_8888);
                Canvas c = new Canvas(ss);
                c.translate(ss.getWidth() / 2, ss.getHeight() / 2);
                c.rotate(degrees);
                c.translate(-dims[0] / 2, -dims[1] / 2);
                c.drawBitmap(mScreenBitmap, 0, 0, null);
                c.setBitmap(null);
                mScreenBitmap = ss;
                if (ss != null && !ss.isRecycled())
                {
                    ss.recycle();
                }
            }

            // If we couldn't take the screenshot, notify the user
            if (mScreenBitmap == null)
            {
                Toast.makeText(context, "screen shot fail", Toast.LENGTH_SHORT).show();
            }

            // Optimizations
            mScreenBitmap.setHasAlpha(false);
            mScreenBitmap.prepareToDraw();

            saveBitmap2file(context, mScreenBitmap, fileFullPath);
        }
    }

}
 
开发者ID:kaixuanluo,项目名称:pc-android-controller-android,代码行数:77,代码来源:ScreentShotUtil.java

示例14: getHit

import android.graphics.Matrix; //导入方法依赖的package包/类
public int getHit(float x, float y) {
    final RectF rect = new RectF(mDrawRect);
    rect.inset(-mPadding, -mPadding);

    final float pts[] = new float[] { x, y };

    final Matrix rotateMatrix = new Matrix();
    rotateMatrix.postTranslate(-rect.centerX(), -rect.centerY());
    rotateMatrix.postRotate(-mRotation);
    rotateMatrix.postTranslate(rect.centerX(), rect.centerY());
    rotateMatrix.mapPoints(pts);

    x = pts[0];
    y = pts[1];

    int retval = NONE;
    final boolean verticalCheck = (y >= (rect.top - HIT_TOLERANCE))
                                  && (y < (rect.bottom + HIT_TOLERANCE));
    final boolean horizCheck = (x >= (rect.left - HIT_TOLERANCE))
                               && (x < (rect.right + HIT_TOLERANCE));

    // if horizontal and vertical checks are good then
    // at least the move edge is selected
    if (verticalCheck && horizCheck) {
        retval = MOVE;
    }

    if (mScaleEnabled) {
        Log.d(LOG_TAG, "scale enabled");
        if ((Math.abs(rect.left - x) < HIT_TOLERANCE) && verticalCheck
            && UIUtils.checkBits(mResizeEdgeMode, GROW_LEFT_EDGE)) {
            Log.d(LOG_TAG, "left");
            retval |= GROW_LEFT_EDGE;
        }
        if ((Math.abs(rect.right - x) < HIT_TOLERANCE) && verticalCheck
            && UIUtils.checkBits(mResizeEdgeMode, GROW_RIGHT_EDGE)) {
            Log.d(LOG_TAG, "right");
            retval |= GROW_RIGHT_EDGE;
        }
        if ((Math.abs(rect.top - y) < HIT_TOLERANCE) && horizCheck
            && UIUtils.checkBits(mResizeEdgeMode, GROW_TOP_EDGE)) {
            Log.d(LOG_TAG, "top");
            retval |= GROW_TOP_EDGE;
        }
        if ((Math.abs(rect.bottom - y) < HIT_TOLERANCE) && horizCheck
            && UIUtils.checkBits(mResizeEdgeMode, GROW_BOTTOM_EDGE)) {
            Log.d(LOG_TAG, "bottom");
            retval |= GROW_BOTTOM_EDGE;
        }
    }

    if ((mRotateEnabled || mScaleEnabled) && (Math.abs(rect.right - x) < HIT_TOLERANCE)
        && (Math.abs(rect.bottom - y) < HIT_TOLERANCE) && verticalCheck && horizCheck) {
        retval = ROTATE;
    }

    if (mMoveEnabled && (retval == NONE) && rect.contains((int) x, (int) y)) {
        retval = MOVE;
    }

    Log.d(LOG_TAG, "retValue: " + retval);

    return retval;
}
 
开发者ID:Sherchen,项目名称:AnimationsDemo,代码行数:65,代码来源:MyHighlightView.java

示例15: onMouseMove

import android.graphics.Matrix; //导入方法依赖的package包/类
public void onMouseMove(int edge, MotionEvent event2, float dx, float dy) {
    if (edge == NONE) {
        return;
    }

    fpoints[0] = dx;
    fpoints[1] = dy;

    float xDelta;
    float yDelta;

    if (edge == MOVE) {
        moveBy(dx * (mCropRect.width() / mDrawRect.width()),
            dy * (mCropRect.height() / mDrawRect.height()));
    } else if (edge == ROTATE) {
        dx = fpoints[0];
        dy = fpoints[1];
        xDelta = dx * (mCropRect.width() / mDrawRect.width());
        yDelta = dy * (mCropRect.height() / mDrawRect.height());
        rotateBy(event2.getX(), event2.getY(), dx, dy);

        invalidate();
        // mContext.invalidate( getInvalidationRect() );
    } else {

        Matrix rotateMatrix = new Matrix();
        rotateMatrix.postRotate(-mRotation);
        rotateMatrix.mapPoints(fpoints);
        dx = fpoints[0];
        dy = fpoints[1];

        if (((GROW_LEFT_EDGE | GROW_RIGHT_EDGE) & edge) == 0)
            dx = 0;
        if (((GROW_TOP_EDGE | GROW_BOTTOM_EDGE) & edge) == 0)
            dy = 0;

        xDelta = dx * (mCropRect.width() / mDrawRect.width());
        yDelta = dy * (mCropRect.height() / mDrawRect.height());

        boolean is_left = UIUtils.checkBits(edge, GROW_LEFT_EDGE);
        boolean is_top = UIUtils.checkBits(edge, GROW_TOP_EDGE);

        float delta;

        if (Math.abs(xDelta) >= Math.abs(yDelta)) {
            delta = xDelta;
            if (is_left) {
                delta *= -1;
            }
        } else {
            delta = yDelta;
            if (is_top) {
                delta *= -1;
            }
        }

        Log.d(LOG_TAG, "x: " + xDelta + ", y: " + yDelta + ", final: " + delta);

        growBy(delta);

        invalidate();
        // mContext.invalidate( getInvalidationRect() );
    }
}
 
开发者ID:Sherchen,项目名称:AnimationsDemo,代码行数:65,代码来源:MyHighlightView.java


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