本文整理了Java中android.graphics.Matrix.preScale()
方法的一些代码示例,展示了Matrix.preScale()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.preScale()
方法的具体详情如下:
包路径:android.graphics.Matrix
类名称:Matrix
方法名:preScale
暂无
代码示例来源:origin: CameraKit/blurkit-android
private Bitmap getBitmapForView(View src, float downscaleFactor) {
Bitmap bitmap = Bitmap.createBitmap(
(int) (src.getWidth() * downscaleFactor),
(int) (src.getHeight() * downscaleFactor),
Bitmap.Config.ARGB_8888
);
Canvas canvas = new Canvas(bitmap);
Matrix matrix = new Matrix();
matrix.preScale(downscaleFactor, downscaleFactor);
canvas.setMatrix(matrix);
src.draw(canvas);
return bitmap;
}
代码示例来源:origin: koral--/android-gif-drawable
@Override
public void onDraw(Canvas canvas, Paint paint, Bitmap buffer) {
if (mCornerRadius == 0) {
canvas.drawBitmap(buffer, null, mDstRectF, paint);
return;
}
if (mShader == null) {
mShader = new BitmapShader(buffer, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
final Matrix shaderMatrix = new Matrix();
shaderMatrix.setTranslate(mDstRectF.left, mDstRectF.top);
shaderMatrix.preScale(mDstRectF.width() / buffer.getWidth(), mDstRectF.height() / buffer.getHeight());
mShader.setLocalMatrix(shaderMatrix);
}
paint.setShader(mShader);
canvas.drawRoundRect(mDstRectF, mCornerRadius, mCornerRadius, paint);
}
}
代码示例来源:origin: scwang90/SmartRefreshLayout
matrix.preScale(sunScale, sunScale);
matrix.postRotate((isRefreshing ? -360 : 360) * mRotate * (isRefreshing ? 1 : SUN_INITIAL_ROTATE_GROWTH),
sunRadius,
代码示例来源:origin: Aspsine/SwipeToLoadLayout
matrix.preScale(sunScale, sunScale);
代码示例来源:origin: CameraKit/blurkit-android
/**
* Users a View reference to create a bitmap, and downscales it using the passed in factor.
* Uses a Rect to crop the view into the bitmap.
* @return Bitmap made from view, downscaled by downscaleFactor.
* @throws NullPointerException
*/
private Bitmap getDownscaledBitmapForView(View view, Rect crop, float downscaleFactor) throws BlurKitException, NullPointerException {
View screenView = view.getRootView();
int width = (int) (crop.width() * downscaleFactor);
int height = (int) (crop.height() * downscaleFactor);
if (screenView.getWidth() <= 0 || screenView.getHeight() <= 0 || width <= 0 || height <= 0) {
throw new BlurKitException("No screen available (width or height = 0)");
}
float dx = -crop.left * downscaleFactor;
float dy = -crop.top * downscaleFactor;
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Matrix matrix = new Matrix();
matrix.preScale(downscaleFactor, downscaleFactor);
matrix.postTranslate(dx, dy);
canvas.setMatrix(matrix);
screenView.draw(canvas);
return bitmap;
}
代码示例来源:origin: square/picasso
matrix.preScale(scaleX, scaleY);
float scale = widthRatio < heightRatio ? widthRatio : heightRatio;
if (shouldResize(onlyScaleDown, inWidth, inHeight, targetWidth, targetHeight)) {
matrix.preScale(scale, scale);
targetHeight != 0 ? targetHeight / (float) inHeight : targetWidth / (float) inWidth;
if (shouldResize(onlyScaleDown, inWidth, inHeight, targetWidth, targetHeight)) {
matrix.preScale(sx, sy);
代码示例来源:origin: airbnb/lottie-android
matrix.preScale(scale, scale);
compositionLayer.draw(canvas, matrix, alpha);
L.endSection("Drawable#draw");
代码示例来源:origin: airbnb/lottie-android
/**
* TODO: see if we can use this for the main {@link #getMatrix()} method.
*/
public Matrix getMatrixForRepeater(float amount) {
if (isIdentity) {
return matrix;
}
PointF position = this.position.getValue();
PointF anchorPoint = this.anchorPoint.getValue();
ScaleXY scale = this.scale.getValue();
float rotation = this.rotation.getValue();
matrix.reset();
matrix.preTranslate(position.x * amount, position.y * amount);
matrix.preScale(
(float) Math.pow(scale.getScaleX(), amount),
(float) Math.pow(scale.getScaleY(), amount));
matrix.preRotate(rotation * amount, anchorPoint.x, anchorPoint.y);
return matrix;
}
代码示例来源:origin: koral--/android-gif-drawable
case FIT_CENTER:
transform.setRectToRect(src, dst, Matrix.ScaleToFit.CENTER);
transform.preScale(scaleX, scaleY);
break;
case FIT_END:
transform.setRectToRect(src, dst, Matrix.ScaleToFit.END);
transform.preScale(scaleX, scaleY);
break;
case FIT_START:
transform.setRectToRect(src, dst, Matrix.ScaleToFit.START);
transform.preScale(scaleX, scaleY);
break;
case FIT_XY:
case MATRIX:
transform.set(mTransform);
transform.preScale(scaleX, scaleY);
break;
代码示例来源:origin: siyamed/android-shape-imageview
sy = np.numbers.get(1);
matrix.preScale(sx, sy);
代码示例来源:origin: airbnb/lottie-android
private void drawCharacterAsGlyph(
FontCharacter character,
Matrix parentMatrix,
float fontScale,
DocumentData documentData,
Canvas canvas) {
List<ContentGroup> contentGroups = getContentsForCharacter(character);
for (int j = 0; j < contentGroups.size(); j++) {
Path path = contentGroups.get(j).getPath();
path.computeBounds(rectF, false);
matrix.set(parentMatrix);
matrix.preTranslate(0, (float) -documentData.baselineShift * Utils.dpScale());
matrix.preScale(fontScale, fontScale);
path.transform(matrix);
if (documentData.strokeOverFill) {
drawGlyph(path, fillPaint, canvas);
drawGlyph(path, strokePaint, canvas);
} else {
drawGlyph(path, strokePaint, canvas);
drawGlyph(path, fillPaint, canvas);
}
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testPreScale() {
final Matrix matrix1 = new Matrix();
matrix1.preScale(2.0f, 2.0f);
assertPointsEqual(mapPoint(matrix1, 1.0f, 1.0f), new PointF(2.0f, 2.0f));
matrix1.preScale(2.0f, 2.0f);
assertPointsEqual(mapPoint(matrix1, 1.0f, 1.0f), new PointF(4.0f, 4.0f));
final Matrix matrix2 = new Matrix();
matrix2.preScale(2.0f, 2.0f, 1.0f, 1.0f);
assertPointsEqual(mapPoint(matrix2, 1.0f, 1.0f), new PointF(1.0f, 1.0f));
matrix2.setTranslate(1.0f, 2.0f);
matrix2.preScale(2.0f, 2.0f, 1.0f, 1.0f);
assertPointsEqual(mapPoint(matrix2, 1.0f, 1.0f), new PointF(2.0f, 3.0f));
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
flipMat.preScale(1.0f, -1.0f);
Bitmap newBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), flipMat, false);
bitmap.recycle();
代码示例来源:origin: Rukey7/MvpApp
matrix.preScale(mVideoScale, mVideoScale);
matrix.postTranslate(mScreenOrWidth * (1 - mVideoScale) / 2,
mScreenOrHeight * (1 - mVideoScale) / 2);
代码示例来源:origin: robolectric/robolectric
@Test
public void set_shouldAddOpsToMatrix() {
final Matrix matrix = new Matrix();
matrix.setScale(1, 1);
matrix.preScale(2, 2, 2, 2);
matrix.postScale(3, 3, 3, 3);
final ShadowMatrix shadow = shadowOf(matrix);
assertThat(shadow.getSetOperations().get("scale")).isEqualTo("1.0 1.0");
assertThat(shadow.getPreOperations().get(0)).isEqualTo("scale 2.0 2.0 2.0 2.0");
assertThat(shadow.getPostOperations().get(0)).isEqualTo("scale 3.0 3.0 3.0 3.0");
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testPreConcat() {
final Matrix matrix = new Matrix();
matrix.preScale(2.0f, 3.0f);
final Matrix translateMatrix = new Matrix();
translateMatrix.setTranslate(5.0f, 7.0f);
matrix.preConcat(translateMatrix);
assertPointsEqual(mapPoint(matrix, 2.0f, 2.0f), new PointF(14.0f, 27.0f));
final Matrix rotateMatrix = new Matrix();
rotateMatrix.setRotate(90.0f);
matrix.preConcat(rotateMatrix);
assertPointsEqual(mapPoint(matrix, 2.0f, 2.0f), new PointF(6.0f, 27.0f));
}
代码示例来源:origin: airbnb/lottie-android
public Matrix getMatrix() {
if (isIdentity) {
return matrix;
}
matrix.reset();
PointF position = this.position.getValue();
if (position.x != 0 || position.y != 0) {
matrix.preTranslate(position.x, position.y);
}
float rotation = ((FloatKeyframeAnimation) this.rotation).getFloatValue();
if (rotation != 0f) {
matrix.preRotate(rotation);
}
ScaleXY scaleTransform = this.scale.getValue();
if (scaleTransform.getScaleX() != 1f || scaleTransform.getScaleY() != 1f) {
matrix.preScale(scaleTransform.getScaleX(), scaleTransform.getScaleY());
}
PointF anchorPoint = this.anchorPoint.getValue();
if (anchorPoint.x != 0 || anchorPoint.y != 0) {
matrix.preTranslate(-anchorPoint.x, -anchorPoint.y);
}
return matrix;
}
代码示例来源:origin: jingle1267/android-utils
/**
* 水平翻转处理
*
* @param bitmap 原图
* @return 水平翻转后的图片
*/
public static Bitmap reverseByHorizontal(Bitmap bitmap) {
Matrix matrix = new Matrix();
matrix.preScale(-1, 1);
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
bitmap.getHeight(), matrix, false);
}
代码示例来源:origin: jingle1267/android-utils
/**
* 垂直翻转处理
*
* @param bitmap 原图
* @return 垂直翻转后的图片
*/
public static Bitmap reverseByVertical(Bitmap bitmap) {
Matrix matrix = new Matrix();
matrix.preScale(1, -1);
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
bitmap.getHeight(), matrix, false);
}
代码示例来源:origin: Blizzard-liu/AndroidUtils
/**
* 水平翻转处理
*
* @param bitmap 原图
* @return 水平翻转后的图片
*/
public static Bitmap reverseByHorizontal(Bitmap bitmap) {
Matrix matrix = new Matrix();
matrix.preScale(-1, 1);
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
bitmap.getHeight(), matrix, false);
}
内容来源于网络,如有侵权,请联系作者删除!