Java Code Examples for android.graphics.Matrix.postRotate()

The following are Jave code examples for showing how to use postRotate() of the android.graphics.Matrix class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: ywApplication   File: FlipLoadingLayout.java   Source Code and License Vote up 6 votes
@Override
protected void onLoadingDrawableSet(Drawable imageDrawable) {
	if (null != imageDrawable) {
		final int dHeight = imageDrawable.getIntrinsicHeight();
		final int dWidth = imageDrawable.getIntrinsicWidth();

		/**
		 * We need to set the width/height of the ImageView so that it is
		 * square with each side the size of the largest drawable dimension.
		 * This is so that it doesn't clip when rotated.
		 */
		ViewGroup.LayoutParams lp = mHeaderImage.getLayoutParams();
		lp.width = lp.height = Math.max(dHeight, dWidth);
		mHeaderImage.requestLayout();

		/**
		 * We now rotate the Drawable so that is at the correct rotation,
		 * and is centered.
		 */
		mHeaderImage.setScaleType(ScaleType.MATRIX);
		Matrix matrix = new Matrix();
		matrix.postTranslate((lp.width - dWidth) / 2f, (lp.height - dHeight) / 2f);
		matrix.postRotate(getDrawableRotationAngle(), lp.width / 2f, lp.height / 2f);
		mHeaderImage.setImageMatrix(matrix);
	}
}
 
Example 2
Project: GitHub   File: ImageRotateUtil.java   Source Code and License Vote up 6 votes
/**
 * 将图片按照某个角度进行旋转
 *
 * @param bm     需要旋转的图片
 * @param degree 旋转角度
 * @return 旋转后的图片
 */
private Bitmap rotateBitmapByDegree(Bitmap bm, int degree) {
    Bitmap returnBm = null;

    // 根据旋转角度,生成旋转矩阵
    Matrix matrix = new Matrix();
    matrix.postRotate(degree);
    try {
        // 将原始图片按照旋转矩阵进行旋转,并得到新的图片
        returnBm = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
    } catch (OutOfMemoryError e) {
    }
    if (returnBm == null) {
        returnBm = bm;
    }
    if (bm != returnBm) {
        bm.recycle();
    }
    return returnBm;
}
 
Example 3
Project: mvparms   File: DrawableProvider.java   Source Code and License Vote up 6 votes
/**
 * 将图片按照某个角度进行旋转
 *
 * @param bm     需要旋转的图片
 * @param degree 旋转角度
 * @return 旋转后的图片
 */
public static Bitmap rotateBitmapByDegree(Bitmap bm, int degree) {
    Bitmap returnBm = null;

    // 根据旋转角度,生成旋转矩阵
    Matrix matrix = new Matrix();
    matrix.postRotate(degree);
    try {
        // 将原始图片按照旋转矩阵进行旋转,并得到新的图片
        returnBm = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
    } catch (OutOfMemoryError e) {
        e.printStackTrace();
    }
    if (returnBm == null) {
        returnBm = bm;
    }
    if (bm != returnBm) {
        bm.recycle();
    }
    return returnBm;
}
 
Example 4
Project: SortingHatAndroid   File: CameraConnectionFragment.java   Source Code and License Vote up 6 votes
/**
 * Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`.
 * This method should be called after the camera preview size is determined in
 * setUpCameraOutputs and also the size of `mTextureView` is fixed.
 *
 * @param viewWidth The width of `mTextureView`
 * @param viewHeight The height of `mTextureView`
 */
private void configureTransform(final int viewWidth, final int viewHeight) {
  final Activity activity = getActivity();
  if (null == textureView || null == previewSize || null == activity) {
    return;
  }
  final int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
  final Matrix matrix = new Matrix();
  final RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
  final RectF bufferRect = new RectF(0, 0, previewSize.getHeight(), previewSize.getWidth());
  final float centerX = viewRect.centerX();
  final float centerY = viewRect.centerY();
  if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
    bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
    matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
    final float scale = Math.max((float) viewHeight / previewSize.getHeight(),
        (float) viewWidth / previewSize.getWidth());
    matrix.postScale(scale, scale, centerX, centerY);
    matrix.postRotate(90 * (rotation - 2), centerX, centerY);
  } else if (Surface.ROTATION_180 == rotation) {
    matrix.postRotate(180, centerX, centerY);
  }
  textureView.setTransform(matrix);
}
 
Example 5
Project: boohee_v5.6   File: BaseImageDecoder.java   Source Code and License Vote up 5 votes
protected Bitmap considerExactScaleAndOrientatiton(Bitmap subsampledBitmap, ImageDecodingInfo
        decodingInfo, int rotation, boolean flipHorizontal) {
    Matrix m = new Matrix();
    ImageScaleType scaleType = decodingInfo.getImageScaleType();
    if (scaleType == ImageScaleType.EXACTLY || scaleType == ImageScaleType.EXACTLY_STRETCHED) {
        float scale = ImageSizeUtils.computeImageScale(new ImageSize(subsampledBitmap
                .getWidth(), subsampledBitmap.getHeight(), rotation), decodingInfo
                .getTargetSize(), decodingInfo.getViewScaleType(), scaleType ==
                ImageScaleType.EXACTLY_STRETCHED);
        if (Float.compare(scale, 1.0f) != 0) {
            m.setScale(scale, scale);
            if (this.loggingEnabled) {
                L.d(LOG_SCALE_IMAGE, srcSize, srcSize.scale(scale), Float.valueOf(scale),
                        decodingInfo.getImageKey());
            }
        }
    }
    if (flipHorizontal) {
        m.postScale(-1.0f, 1.0f);
        if (this.loggingEnabled) {
            L.d(LOG_FLIP_IMAGE, decodingInfo.getImageKey());
        }
    }
    if (rotation != 0) {
        m.postRotate((float) rotation);
        if (this.loggingEnabled) {
            L.d(LOG_ROTATE_IMAGE, Integer.valueOf(rotation), decodingInfo.getImageKey());
        }
    }
    Bitmap finalBitmap = Bitmap.createBitmap(subsampledBitmap, 0, 0, subsampledBitmap
            .getWidth(), subsampledBitmap.getHeight(), m, true);
    if (finalBitmap != subsampledBitmap) {
        subsampledBitmap.recycle();
    }
    return finalBitmap;
}
 
Example 6
Project: greendao_expand   File: CircleProgressView.java   Source Code and License Vote up 5 votes
private void setupBarPaint() {
    if (mBarColors.length > 1) {
        mBarPaint.setShader(new SweepGradient(mCircleBounds.centerX(), mCircleBounds.centerY(), mBarColors, null));
        Matrix matrix = new Matrix();
        mBarPaint.getShader().getLocalMatrix(matrix);

        matrix.postTranslate(-mCircleBounds.centerX(), -mCircleBounds.centerY());
        matrix.postRotate(mStartAngle);
        matrix.postTranslate(mCircleBounds.centerX(), mCircleBounds.centerY());
        mBarPaint.getShader().setLocalMatrix(matrix);
        mBarPaint.setColor(mBarColors[0]);
    } else if (mBarColors.length == 1) {
        mBarPaint.setColor(mBarColors[0]);
        mBarPaint.setShader(null);
    } else {
        mBarPaint.setColor(mBarColorStandard);
        mBarPaint.setShader(null);
    }

    mBarPaint.setAntiAlias(true);
    mBarPaint.setStrokeCap(mBarStrokeCap);
    mBarPaint.setStyle(Style.STROKE);
    mBarPaint.setStrokeWidth(mBarWidth);

    if (mBarStrokeCap != Paint.Cap.BUTT) {
        mShaderlessBarPaint = new Paint(mBarPaint);
        mShaderlessBarPaint.setShader(null);
        mShaderlessBarPaint.setColor(mBarColors[0]);
    }
}
 
Example 7
Project: SimpleDialogFragments   File: ColorWheelView.java   Source Code and License Vote up 5 votes
@Override
protected void updateRotationDependant() {
    super.updateRotationDependant();

    Matrix rotationMatrix = new Matrix();
    rotationMatrix.postRotate(mRotation, mCenter.x, mCenter.y);

    for (Field field : mFields) {
        field.rawPath.transform(rotationMatrix, /* to */ field.cachedPath);
    }
}
 
Example 8
Project: Remindy   File: EditImageAttachmentActivity.java   Source Code and License Vote up 5 votes
private void applyPendingRotation() {
    if(mRotation != 0) {
        //Normalize rotation
        mRotation = mRotation % 360;
        if (mRotation < 0) mRotation += 360;

        //Get the bitmap
        File imageFile = new File(FileUtil.getImageAttachmentDir(this), mImageAttachment.getImageFilename());
        Bitmap imageBitmap = ImageUtil.getBitmap(imageFile);

        //Rotate it
        Matrix matrix = new Matrix();
        matrix.postRotate(mRotation);
        imageBitmap = Bitmap.createBitmap(imageBitmap, 0, 0, imageBitmap.getWidth(), imageBitmap.getHeight(), matrix, true);

        try {
            ImageUtil.saveBitmapAsJpeg(imageFile, imageBitmap, IMAGE_COMPRESSION_PERCENTAGE);
        }catch (IOException e) {
            SnackbarUtil.showSnackbar(mContainer, SnackbarUtil.SnackbarType.ERROR, R.string.activity_edit_image_attachment_snackbar_error_could_not_rotate, SnackbarUtil.SnackbarDuration.LONG, null);
        }

        //Reload ImageView
        mImage.setImageBitmap(imageBitmap);
        mImage.setRotation(0);

        //Reset Rotation
        mRotation = 0;
    }
}
 
Example 9
Project: WithYou   File: FaceUtil.java   Source Code and License Vote up 5 votes
/**
 * ��תͼƬ
 * 
 * @param angle	��ת�Ƕ�
 * @param bitmap ԭͼ
 * @return bitmap ��ת���ͼƬ
 */
public static Bitmap rotateImage(int angle, Bitmap bitmap) {
	// ͼƬ��ת����
	Matrix matrix = new Matrix();
	matrix.postRotate(angle);
	// �õ���ת���ͼƬ
	Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,
			bitmap.getWidth(), bitmap.getHeight(), matrix, true);
	return resizedBitmap;
}
 
Example 10
Project: react-native-face-detect   File: Converter.java   Source Code and License Vote up 5 votes
public static void prepareMatrix(Matrix matrix, boolean mirror, int displayOrientation,
                                 int viewWidth, int viewHeight) {
  // Need mirror for front camera.
  matrix.setScale(mirror ? -1 : 1, 1);
  // This is the value for android.hardware.Camera.setDisplayOrientation.
  matrix.postRotate(displayOrientation);
  // Camera driver coordinates range from (-1000, -1000) to (1000, 1000).
  // UI coordinates range from (0, 0) to (width, height).
  matrix.postScale(viewWidth / 2000f, viewHeight / 2000f);
  matrix.postTranslate(viewWidth / 2f, viewHeight / 2f);
}
 
Example 11
Project: GitHub   File: BaseImageDecoder.java   Source Code and License Vote up 5 votes
protected Bitmap considerExactScaleAndOrientatiton(Bitmap subsampledBitmap, ImageDecodingInfo decodingInfo,
		int rotation, boolean flipHorizontal) {
	Matrix m = new Matrix();
	// Scale to exact size if need
	ImageScaleType scaleType = decodingInfo.getImageScaleType();
	if (scaleType == ImageScaleType.EXACTLY || scaleType == ImageScaleType.EXACTLY_STRETCHED) {
		ImageSize srcSize = new ImageSize(subsampledBitmap.getWidth(), subsampledBitmap.getHeight(), rotation);
		float scale = ImageSizeUtils.computeImageScale(srcSize, decodingInfo.getTargetSize(), decodingInfo
				.getViewScaleType(), scaleType == ImageScaleType.EXACTLY_STRETCHED);
		if (Float.compare(scale, 1f) != 0) {
			m.setScale(scale, scale);

			if (loggingEnabled) {
				L.d(LOG_SCALE_IMAGE, srcSize, srcSize.scale(scale), scale, decodingInfo.getImageKey());
			}
		}
	}
	// Flip bitmap if need
	if (flipHorizontal) {
		m.postScale(-1, 1);

		if (loggingEnabled) L.d(LOG_FLIP_IMAGE, decodingInfo.getImageKey());
	}
	// Rotate bitmap if need
	if (rotation != 0) {
		m.postRotate(rotation);

		if (loggingEnabled) L.d(LOG_ROTATE_IMAGE, rotation, decodingInfo.getImageKey());
	}

	Bitmap finalBitmap = Bitmap.createBitmap(subsampledBitmap, 0, 0, subsampledBitmap.getWidth(), subsampledBitmap
			.getHeight(), m, true);
	if (finalBitmap != subsampledBitmap) {
		subsampledBitmap.recycle();
	}
	return finalBitmap;
}
 
Example 12
Project: AnimationsDemo   File: MyHighlightView.java   Source Code and License Vote up 5 votes
public boolean forceUpdate() {
    Log.i(LOG_TAG, "forceUpdate");

    RectF cropRect = getCropRectF();
    RectF drawRect = getDrawRect();

    if (mEditableContent != null) {

        final float textWidth = mContent.getCurrentWidth();
        final float textHeight = mContent.getCurrentHeight();

        updateRatio();

        RectF textRect = new RectF(cropRect);
        getMatrix().mapRect(textRect);

        float dx = textWidth - textRect.width();
        float dy = textHeight - textRect.height();

        float[] fpoints = new float[] { dx, dy };

        Matrix rotateMatrix = new Matrix();
        rotateMatrix.postRotate(-mRotation);

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

        float xDelta = dx * (cropRect.width() / drawRect.width());
        float yDelta = dy * (cropRect.height() / drawRect.height());

        if (xDelta != 0 || yDelta != 0) {
            growBy(xDelta / 2, yDelta / 2, false);
        }

        invalidate();
        return true;
    }
    return false;
}
 
Example 13
Project: MyAnimeViewer   File: RotateBitmap.java   Source Code and License Vote up 5 votes
public Matrix getRotateMatrix() {
    // By default this is an identity matrix.
    Matrix matrix = new Matrix();
    if (mRotation != 0) {
        // We want to do the rotation at origin, but since the bounding
        // rectangle will be changed after rotation, so the delta values
        // are based on old & new width/height respectively.
        int cx = mBitmap.getWidth() / 2;
        int cy = mBitmap.getHeight() / 2;
        matrix.preTranslate(-cx, -cy);
        matrix.postRotate(mRotation);
        matrix.postTranslate(getWidth() / 2, getHeight() / 2);
    }
    return matrix;
}
 
Example 14
Project: AnimationsDemo   File: MyHighlightView.java   Source Code and License Vote up 4 votes
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() );
    }
}
 
Example 15
Project: DripUltraRefreshWithLoad   File: StoreHouseFooter.java   Source Code and License Vote up 4 votes
@Override
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    float progress = mProgress;
    int c1 = canvas.save();
    int len = mItemList.size();

    for (int i = 0; i < len; i++) {

        canvas.save();
        StoreHouseBarItem storeHouseBarItem = mItemList.get(i);
        float offsetX = mOffsetX + storeHouseBarItem.midPoint.x;
        float offsetY = mOffsetY + storeHouseBarItem.midPoint.y;

        if (mIsInLoading) {
            storeHouseBarItem.getTransformation(getDrawingTime(), mTransformation);
            canvas.translate(offsetX, offsetY);
        } else {

            if (progress == 0) {
                storeHouseBarItem.resetPosition(mHorizontalRandomness);
                continue;
            }

            float startPadding = (1 - mInternalAnimationFactor) * i / len;
            float endPadding = 1 - mInternalAnimationFactor - startPadding;

            // done
            if (progress == 1 || progress >= 1 - endPadding) {
                canvas.translate(offsetX, offsetY);
                storeHouseBarItem.setAlpha(mBarDarkAlpha);
            } else {
                float realProgress;
                if (progress <= startPadding) {
                    realProgress = 0;
                } else {
                    realProgress = Math.min(1, (progress - startPadding) / mInternalAnimationFactor);
                }
                offsetX += storeHouseBarItem.translationX * (1 - realProgress);
                offsetY += -mDropHeight * (1 - realProgress);
                Matrix matrix = new Matrix();
                matrix.postRotate(360 * realProgress);
                matrix.postScale(realProgress, realProgress);
                matrix.postTranslate(offsetX, offsetY);
                storeHouseBarItem.setAlpha(mBarDarkAlpha * realProgress);
                canvas.concat(matrix);
            }
        }
        storeHouseBarItem.draw(canvas);
        canvas.restore();
    }
    if (mIsInLoading) {
        invalidate();
    }
    canvas.restoreToCount(c1);
}
 
Example 16
Project: susi_android_v1   File: ChatMessageView.java   Source Code and License Vote up 4 votes
public Bitmap rotateBitmap(Bitmap source, float angle) {
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);
    return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
}
 
Example 17
Project: aos-MediaLib   File: AvosBitmapHelper.java   Source Code and License Vote up 4 votes
public static Bitmap createRGBBitmap(int[] inData,
        int inWidth, int inHeight, int inLinestep,
        int inRotation,
        int outWidth, int outHeight) {

    Log.d("AvosBitmapHelper", "createRGBBitmap("+inData.length+","+inWidth+","+inHeight+","+inLinestep+","+inRotation+","+outWidth+","+outHeight+")");
    if (inWidth == 0 || inHeight == 0)
        return null;
    if (outWidth == 0 || outHeight == 0) {
        outWidth = inWidth;
        outHeight = inHeight;
    }

    Config config = Bitmap.Config.ARGB_8888;
    Bitmap bitmap = Bitmap.createBitmap(inData, 0, inLinestep, inWidth, inHeight, config);
    if (bitmap == null)
        return null;

    if (inRotation != 0) {
        if (inRotation == 90 || inRotation == 270) {
            int tmp = outWidth;
            outWidth = outHeight;
            outHeight = tmp;
        }

        Matrix matrix = new Matrix();
        matrix.postRotate(inRotation);
        Bitmap rotatedBitmap =  Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
        if (rotatedBitmap != bitmap)
            bitmap.recycle();
        bitmap = rotatedBitmap;
    }

    if (outWidth != inWidth || outHeight != inHeight) {
        Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, outWidth, outHeight, true);
        if (scaledBitmap != bitmap)
            bitmap.recycle();
        bitmap = scaledBitmap;
    }

    return bitmap;
}
 
Example 18
Project: Swface   File: StoreHouseHeader.java   Source Code and License Vote up 4 votes
@Override
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    float progress = mProgress;
    int c1 = canvas.save();
    int len = mItemList.size();

    for (int i = 0; i < len; i++) {

        canvas.save();
        StoreHouseBarItem storeHouseBarItem = mItemList.get(i);
        float offsetX = mOffsetX + storeHouseBarItem.midPoint.x;
        float offsetY = mOffsetY + storeHouseBarItem.midPoint.y;

        if (mIsInLoading) {
            storeHouseBarItem.getTransformation(getDrawingTime(), mTransformation);
            canvas.translate(offsetX, offsetY);
        } else {

            if (progress == 0) {
                storeHouseBarItem.resetPosition(mHorizontalRandomness);
                continue;
            }

            float startPadding = (1 - mInternalAnimationFactor) * i / len;
            float endPadding = 1 - mInternalAnimationFactor - startPadding;

            // done
            if (progress == 1 || progress >= 1 - endPadding) {
                canvas.translate(offsetX, offsetY);
                storeHouseBarItem.setAlpha(mBarDarkAlpha);
            } else {
                float realProgress;
                if (progress <= startPadding) {
                    realProgress = 0;
                } else {
                    realProgress = Math.min(1, (progress - startPadding) / mInternalAnimationFactor);
                }
                offsetX += storeHouseBarItem.translationX * (1 - realProgress);
                offsetY += -mDropHeight * (1 - realProgress);
                Matrix matrix = new Matrix();
                matrix.postRotate(360 * realProgress);
                matrix.postScale(realProgress, realProgress);
                matrix.postTranslate(offsetX, offsetY);
                storeHouseBarItem.setAlpha(mBarDarkAlpha * realProgress);
                canvas.concat(matrix);
            }
        }
        storeHouseBarItem.draw(canvas);
        canvas.restore();
    }
    if (mIsInLoading) {
        invalidate();
    }
    canvas.restoreToCount(c1);
}
 
Example 19
Project: PaoMovie   File: StoreHouseHeader.java   Source Code and License Vote up 4 votes
@Override
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    float progress = mProgress;
    int c1 = canvas.save();
    int len = mItemList.size();

    for (int i = 0; i < len; i++) {

        canvas.save();
        StoreHouseBarItem storeHouseBarItem = mItemList.get(i);
        float offsetX = mOffsetX + storeHouseBarItem.midPoint.x;
        float offsetY = mOffsetY + storeHouseBarItem.midPoint.y;

        if (mIsInLoading) {
            storeHouseBarItem.getTransformation(getDrawingTime(), mTransformation);
            canvas.translate(offsetX, offsetY);
        } else {

            if (progress == 0) {
                storeHouseBarItem.resetPosition(mHorizontalRandomness);
                continue;
            }

            float startPadding = (1 - mInternalAnimationFactor) * i / len;
            float endPadding = 1 - mInternalAnimationFactor - startPadding;

            // done
            if (progress == 1 || progress >= 1 - endPadding) {
                canvas.translate(offsetX, offsetY);
                storeHouseBarItem.setAlpha(mBarDarkAlpha);
            } else {
                float realProgress;
                if (progress <= startPadding) {
                    realProgress = 0;
                } else {
                    realProgress = Math.min(1, (progress - startPadding) / mInternalAnimationFactor);
                }
                offsetX += storeHouseBarItem.translationX * (1 - realProgress);
                offsetY += -mDropHeight * (1 - realProgress);
                Matrix matrix = new Matrix();
                matrix.postRotate(360 * realProgress);
                matrix.postScale(realProgress, realProgress);
                matrix.postTranslate(offsetX, offsetY);
                storeHouseBarItem.setAlpha(mBarDarkAlpha * realProgress);
                canvas.concat(matrix);
            }
        }
        storeHouseBarItem.draw(canvas);
        canvas.restore();
    }
    if (mIsInLoading) {
        invalidate();
    }
    canvas.restoreToCount(c1);
}
 
Example 20
Project: Hotspot-master-devp   File: BitmapUtils.java   Source Code and License Vote up 3 votes
public Bitmap getRotateBitmap(Bitmap toTransform,int rotateRotationAngle) {
    Matrix matrix = new Matrix();

    matrix.postRotate(rotateRotationAngle);

    return Bitmap.createBitmap(toTransform, 0, 0, toTransform.getWidth(), toTransform.getHeight(), matrix, true);

}