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


Java Matrix.preRotate方法代码示例

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


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

示例1: onSizeChanged

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
protected void onSizeChanged(int width, int height, int oldw, int oldh) {

    int centerX = width / 2;
    int centerY = height / 2;

    innerPadding = (int) (paramInnerPadding * width / 100);
    outerPadding = (int) (paramOuterPadding * width / 100);
    arrowPointerSize = (int) (paramArrowPointerSize * width / 100);
    valueSliderWidth = (int) (paramValueSliderWidth * width / 100);

    outerWheelRadius = width / 2 - outerPadding - arrowPointerSize;
    innerWheelRadius = outerWheelRadius - valueSliderWidth;
    colorWheelRadius = innerWheelRadius - innerPadding;

    outerWheelRect.set(centerX - outerWheelRadius, centerY - outerWheelRadius, centerX + outerWheelRadius, centerY + outerWheelRadius);
    innerWheelRect.set(centerX - innerWheelRadius, centerY - innerWheelRadius, centerX + innerWheelRadius, centerY + innerWheelRadius);

    colorWheelBitmap = createColorWheelBitmap(colorWheelRadius * 2, colorWheelRadius * 2);

    gradientRotationMatrix = new Matrix();
    gradientRotationMatrix.preRotate(270, width / 2, height / 2);

    colorViewPath.arcTo(outerWheelRect, 270, -180);
    colorViewPath.arcTo(innerWheelRect, 90, 180);

    valueSliderPath.arcTo(outerWheelRect, 270, 180);
    valueSliderPath.arcTo(innerWheelRect, 90, -180);

}
 
开发者ID:MLNO,项目名称:airgram,代码行数:31,代码来源:ColorPicker.java

示例2: onSizeChanged

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
protected void onSizeChanged(int width, int height, int oldw, int oldh) {

    int centerX = width / 2;
    int centerY = height / 2;

    innerPadding = (int) (paramInnerPadding * width / 100);
    outerPadding = (int) (paramOuterPadding * width / 100);
    arrowPointerSize = (int) (paramArrowPointerSize * width / 100);
    valueSliderWidth = (int) (paramValueSliderWidth * width / 100);

    outerWheelRadius = width / 2 - outerPadding - arrowPointerSize;
    innerWheelRadius = outerWheelRadius - valueSliderWidth;
    colorWheelRadius = innerWheelRadius - innerPadding;

    outerWheelRect.set(centerX - outerWheelRadius, centerY - outerWheelRadius, centerX + outerWheelRadius, centerY + outerWheelRadius);
    innerWheelRect.set(centerX - innerWheelRadius, centerY - innerWheelRadius, centerX + innerWheelRadius, centerY + innerWheelRadius);

    colorWheelBitmap = createColorWheelBitmap(colorWheelRadius * 2, colorWheelRadius * 2);

    gradientRotationMatrix = new Matrix();
    gradientRotationMatrix.preRotate(270, width / 2, height / 2);

    valueSliderPath.arcTo(outerWheelRect, 270, 180);
    valueSliderPath.arcTo(innerWheelRect, 90, -180);

}
 
开发者ID:MLNO,项目名称:airgram,代码行数:28,代码来源:MultiColorPicker.java

示例3: rotateBitmap

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Rotate the bitmap a given amount of degrees. This is used to get the correct bitmap when
 * the device is in landscape mode.
 * @param bitmap
 * @param degrees
 * @return a rotated bitmap
 */
public static Bitmap rotateBitmap(Bitmap bitmap, int degrees) {
    int w = bitmap.getWidth();
    int h = bitmap.getHeight();
    // Setting pre rotate
    Matrix mtx = new Matrix();
    mtx.preRotate(degrees);
    // Rotating Bitmap
    Bitmap rotated = Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, true);
    return Bitmap.createScaledBitmap(rotated, bitmap.getWidth(), bitmap.getHeight(), true);
}
 
开发者ID:digital-voting-pass,项目名称:polling-station-app,代码行数:18,代码来源:CameraFragmentUtil.java

示例4: setRectToRect

import android.graphics.Matrix; //导入方法依赖的package包/类
public static void setRectToRect(Matrix matrix, RectF src, RectF dst, int rotation, Matrix.ScaleToFit align) {
    float tx, sx;
    float ty, sy;
    if (rotation == 90 || rotation == 270) {
        sx = dst.height() / src.width();
        sy = dst.width() / src.height();
    } else {
        sx = dst.width() / src.width();
        sy = dst.height() / src.height();
    }
    if (align != Matrix.ScaleToFit.FILL) {
        if (sx > sy) {
            sx = sy;
        } else {
            sy = sx;
        }
    }
    tx = -src.left * sx;
    ty = -src.top * sy;

    matrix.setTranslate(dst.left, dst.top);
    if (rotation == 90) {
        matrix.preRotate(90);
        matrix.preTranslate(0, -dst.width());
    } else if (rotation == 180) {
        matrix.preRotate(180);
        matrix.preTranslate(-dst.width(), -dst.height());
    } else if (rotation == 270) {
        matrix.preRotate(270);
        matrix.preTranslate(-dst.height(), 0);
    }

    matrix.preScale(sx, sy);
    matrix.preTranslate(tx, ty);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:36,代码来源:AndroidUtilities.java

示例5: onDraw

import android.graphics.Matrix; //导入方法依赖的package包/类
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    RectF oval = new RectF(8.0f, 8.0f, (float) (this.mSize - 8), (float) (this.mSize - 8));
    Paint bgPaint = new Paint();
    bgPaint.setAntiAlias(true);
    bgPaint.setStrokeWidth(2.0f);
    bgPaint.setStyle(Style.STROKE);
    bgPaint.setColor(this.CIRCLE_INDICATOR_COLOR);
    canvas.drawArc(oval, 0.0f, 360.0f, false, bgPaint);
    Paint circlePaint = new Paint();
    circlePaint.setAntiAlias(true);
    circlePaint.setStrokeWidth(8.0f);
    circlePaint.setStyle(Style.STROKE);
    circlePaint.setStrokeCap(Cap.ROUND);
    Matrix matrix = new Matrix();
    matrix.preRotate(-90.0f, (float) (this.mSize / 2), (float) (this.mSize / 2));
    SweepGradient gradient = new SweepGradient((float) (this.mSize / 2), (float) (this
            .mSize / 2), this.CIRCLE_STROKE_COLOR, this.CIRCLE_STROKE_COLOR_END);
    gradient.setLocalMatrix(matrix);
    circlePaint.setShader(gradient);
    canvas.drawArc(oval, -90.0f, (float) this.mProgress, false, circlePaint);
    Paint fullPaint = new Paint();
    fullPaint.setAntiAlias(true);
    fullPaint.setStyle(Style.FILL);
    fullPaint.setStrokeCap(Cap.ROUND);
    if (this.mProgress == 360) {
        fullPaint.setColor(this.CIRCLE_STROKE_COLOR_END);
    } else {
        fullPaint.setColor(this.CIRCLE_STROKE_COLOR);
    }
    canvas.drawCircle((float) (this.mSize / 2), 8.0f, aj.hA, fullPaint);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:33,代码来源:ProgressIndicator.java

示例6: onSizeChanged

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
protected void onSizeChanged(int width, int height, int oldw, int oldh) {

    int centerX = width / 2;
    int centerY = height / 2;

    innerPadding = paramInnerPadding * width / 100;
    outerPadding = paramOuterPadding * width / 100;
    arrowPointerSize = paramArrowPointerSize * width / 100;
    valueSliderWidth = paramValueSliderWidth * width / 100;

    outerWheelRadius = width / 2 - outerPadding - arrowPointerSize;
    innerWheelRadius = outerWheelRadius - valueSliderWidth;
    colorWheelRadius = innerWheelRadius - innerPadding;

    outerWheelRect.set(centerX - outerWheelRadius, centerY
            - outerWheelRadius, centerX + outerWheelRadius, centerY
            + outerWheelRadius);
    innerWheelRect.set(centerX - innerWheelRadius, centerY
            - innerWheelRadius, centerX + innerWheelRadius, centerY
            + innerWheelRadius);

    colorWheelBitmap = createColorWheelBitmap(colorWheelRadius * 2,
            colorWheelRadius * 2);

    gradientRotationMatrix = new Matrix();
    gradientRotationMatrix.preRotate(270, width / 2, height / 2);

    colorViewPath.arcTo(outerWheelRect, 270, -180);
    colorViewPath.arcTo(innerWheelRect, 90, 180);

    valueSliderPath.arcTo(outerWheelRect, 270, 180);
    valueSliderPath.arcTo(innerWheelRect, 90, -180);

}
 
开发者ID:89luca89,项目名称:ThunderMusic,代码行数:36,代码来源:ColorPicker.java

示例7: drawFan

import android.graphics.Matrix; //导入方法依赖的package包/类
private void drawFan(Canvas canvas){
    int centerX = (int) mTotalProgressWidth;
    int centerY = 8;
    if(mProgress == 100){
        String text = "100%";
        canvas.drawText(text,centerX,mPicHeight/2+getTextHeight(text)/2,mFanPaint);
    }else{
        Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), R.mipmap.fengshan);
        int bitmapWidth = bitmap.getWidth();
        int bitmapHeight = bitmap.getHeight();

        Matrix matrix = new Matrix();
        matrix.setTranslate(centerX, centerY);     //设置图片的原点坐标
        if (this.mProgress >= 95 && this.mProgress < 100){
            float scale = Math.abs(this.mProgress - 100) * 0.2f;
            //缩放 参数1:X轴缩放倍数,参数2:Y轴缩放倍数 参数3,4:缩放中心点
            matrix.preScale(scale,scale,(float)bitmapWidth/2, (float)bitmapHeight/2);
        }else{
            //旋转 参数1:角度,参数2,3:旋转中心点
            matrix.preRotate(mAngle, (float)bitmapWidth/2, (float)bitmapHeight/2);
        }
        canvas.drawBitmap(bitmap, matrix, mFanPaint);
        if (this.mProgress != 100){
            mAngle += 60;
        }
    }
}
 
开发者ID:hacjy,项目名称:LeafLoadingView,代码行数:28,代码来源:LeafLoadingView.java

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

示例9: onDraw

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    final int store = canvas.save();
    //参数修正
    int w = getMeasuredWidth();
    int h = getMeasuredHeight();




    //圆心
    int x = w/2;
    int y = h/2;
    //半径
    int radius = (Math.min(w,h)-2*padding)/2-internalStrokeWidth/2;//半径
    //线冒的范围,默认在roate 为0的位置,之后通过旋转摆正
    recthead = new RectF(x+radius-internalStrokeWidth/2,y-internalStrokeWidth/2,
            x+radius+internalStrokeWidth/2,y+internalStrokeWidth/2);

    calculatePercentEndColor(pre);
    sweepGradient = new SweepGradient(x,y,colors,dur);
    //旋转sweepGradient的角度
    Matrix gradientMatrix = new Matrix();
    gradientMatrix.preRotate(roate, x, y);
    sweepGradient.setLocalMatrix(gradientMatrix);

    outpaint.setShader(sweepGradient);


    //绘制背景
    canvas.drawCircle(x,y,radius+internalStrokeWidth/2+padding,bgpaint);

    //绘制外部单元格
    canvas.drawCircle(x,y,radius,outpaint);

    //如果是非dash样式,线冒会被染色为终点颜色.例如红色,这里需要一个半圆盖着
    if(!dash){
        //为保证旋转不画布其他元素生效
        if(pre>0&&pre<1) {
            canvas.save();
            // 绘制开头的半圆,线冒
            canvas.rotate(roate, x, y);
            canvas.drawArc(recthead, 180, 180, true, startPaint);
            canvas.restore();
        }
        // 绘制结束的半圆,线冒
        if (pre>0&&pre <= 1) {
            //为保证旋转不画布其他元素生效
            canvas.save();
            endPaint.setColor(percentEndColor);
            //-1个角度,因为计算后有一定的精度损失
            canvas.rotate(roate+360*pre-1, x, y);
            canvas.drawArc(recthead, 0f, 180f, true, endPaint);
            canvas.restore();
        }


    }

    canvas.restoreToCount(store);

}
 
开发者ID:jiongjiongxia,项目名称:DashProgress,代码行数:64,代码来源:DashProgressCircle.java

示例10: preRotateBitmap

import android.graphics.Matrix; //导入方法依赖的package包/类
public static Bitmap preRotateBitmap(Bitmap source, float angle) {
    Matrix matrix = new Matrix();
    matrix.preRotate(angle);
    return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, false);
}
 
开发者ID:simplezhli,项目名称:Tesseract-OCR-Scanner,代码行数:6,代码来源:Tools.java

示例11: drawJet

import android.graphics.Matrix; //导入方法依赖的package包/类
private void drawJet(Canvas canvas) {
    Matrix matrix = mMatrix;
    matrix.reset();

    float dragPercent = mPercent;
    float rotateAngle = 0;

    // Check overdrag
    if (dragPercent > 1.0f && !mEndOfRefreshing) {
        if (dragPercent > 2)
            dragPercent = 2;
        rotateAngle = (dragPercent - 1) * 10;
        dragPercent = 1.0f;
    }
    if (mEndOfRefreshing) {
        dragPercent = 2 - dragPercent;
    }

    float offsetX = ((mScreenWidth * dragPercent) / 2) - mJetWidthCenter;

    float offsetY = mJetTopOffset
            + (getTotalDragDistance / 2)
            * (1.0f - dragPercent)
            - mJetHeightCenter;

    if (isRefreshing) {
        if (checkCurrentAnimationPart(AnimationPart.FIRST)) {
            offsetY -= getAnimationPartValue(AnimationPart.FIRST);
        } else if (checkCurrentAnimationPart(AnimationPart.SECOND)) {
            offsetY -= getAnimationPartValue(AnimationPart.SECOND);
        } else if (checkCurrentAnimationPart(AnimationPart.THIRD)) {
            offsetY += getAnimationPartValue(AnimationPart.THIRD);
        } else if (checkCurrentAnimationPart(AnimationPart.FOURTH)) {
            offsetY += getAnimationPartValue(AnimationPart.FOURTH);
        }
    }

    matrix.setTranslate(offsetX, offsetY);

    if (dragPercent == 1.0f) {
        matrix.preRotate(rotateAngle, mJetWidthCenter, mJetHeightCenter);
    }

    canvas.drawBitmap(mJet, matrix, null);
}
 
开发者ID:tohodog,项目名称:QSRefreshLayout,代码行数:46,代码来源:PlainRefreshDraw.java


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