本文整理了Java中android.widget.ImageView.getImageMatrix()
方法的一些代码示例,展示了ImageView.getImageMatrix()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.getImageMatrix()
方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:getImageMatrix
暂无
代码示例来源:origin: andkulikov/Transitions-Everywhere
public static void animateTransform(@NonNull ImageView imageView, @Nullable Matrix matrix) {
Drawable drawable = imageView.getDrawable();
if (drawable == null) {
return;
}
if (matrix == null || drawable.getIntrinsicWidth() == -1
|| drawable.getIntrinsicHeight() == -1) {
drawable.setBounds(0, 0, imageView.getWidth(), imageView.getHeight());
} else {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
Matrix drawMatrix = imageView.getImageMatrix();
if (drawMatrix.isIdentity()) {
drawMatrix = new Matrix();
ReflectionUtils.setFieldValue(imageView, FIELD_DRAW_MATRIX, drawMatrix);
}
drawMatrix.set(matrix);
}
imageView.invalidate();
}
代码示例来源:origin: stackoverflow.com
imageView.getImageMatrix().getValues(f);
代码示例来源:origin: andkulikov/Transitions-Everywhere
ImageView.ScaleType scaleType = imageView.getScaleType();
if (scaleType == ImageView.ScaleType.FIT_XY) {
matrix = imageView.getImageMatrix();
if (!matrix.isIdentity()) {
matrix = new Matrix(matrix);
matrix = new Matrix(imageView.getImageMatrix());
代码示例来源:origin: bm-x/PhotoView
public static Info getImageViewInfo(ImageView imgView) {
int[] p = new int[2];
getLocation(imgView, p);
Drawable drawable = imgView.getDrawable();
Matrix matrix = imgView.getImageMatrix();
int width = getDrawableWidth(drawable);
int height = getDrawableHeight(drawable);
RectF imgRect = new RectF(0, 0, width, height);
matrix.mapRect(imgRect);
RectF rect = new RectF(p[0] + imgRect.left, p[1] + imgRect.top, p[0] + imgRect.right, p[1] + imgRect.bottom);
RectF widgetRect = new RectF(0, 0, imgView.getWidth(), imgView.getHeight());
RectF baseRect = new RectF(widgetRect);
PointF screenCenter = new PointF(widgetRect.width() / 2, widgetRect.height() / 2);
return new Info(rect, imgRect, widgetRect, baseRect, screenCenter, 1, 0, imgView.getScaleType());
}
代码示例来源:origin: Hitomis/transferee
public static PhotoInfo getImageViewInfo(ImageView imgView) {
int[] p = new int[2];
getLocation(imgView, p);
Drawable drawable = imgView.getDrawable();
Matrix matrix = imgView.getImageMatrix();
int width = getDrawableWidth(drawable);
int height = getDrawableHeight(drawable);
RectF imgRect = new RectF(0, 0, width, height);
matrix.mapRect(imgRect);
RectF rect = new RectF(p[0] + imgRect.left, p[1] + imgRect.top, p[0] + imgRect.right, p[1] + imgRect.bottom);
RectF widgetRect = new RectF(0, 0, imgView.getWidth(), imgView.getHeight());
RectF baseRect = new RectF(widgetRect);
PointF screenCenter = new PointF(widgetRect.width() / 2, widgetRect.height() / 2);
return new PhotoInfo(rect, imgRect, widgetRect, baseRect, screenCenter, 1, 0, imgView.getScaleType());
}
代码示例来源:origin: JingYeoh/FragmentRigger
imageView.getImageMatrix().getValues(f);
代码示例来源:origin: stackoverflow.com
public static int[] getBitmapOffset(ImageView img, Boolean includeLayout) {
int[] offset = new int[2];
float[] values = new float[9];
Matrix m = img.getImageMatrix();
m.getValues(values);
offset[0] = (int) values[5];
offset[1] = (int) values[2];
if (includeLayout) {
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) img.getLayoutParams();
int paddingTop = (int) (img.getPaddingTop() );
int paddingLeft = (int) (img.getPaddingLeft() );
offset[0] += paddingTop + lp.topMargin;
offset[1] += paddingLeft + lp.leftMargin;
}
return offset;
}
代码示例来源:origin: stackoverflow.com
<pre>
final float[] getPointerCoords(ImageView view, MotionEvent e)
{
final int index = e.getActionIndex();
final float[] coords = new float[] { e.getX(index), e.getY(index) };
Matrix matrix = new Matrix();
view.getImageMatrix().invert(matrix);
matrix.postTranslate(view.getScrollX(), view.getScrollY());
matrix.mapPoints(coords);
return coords;
}
</pre>
代码示例来源:origin: alexvasilkov/GestureViews
imageView.getImageMatrix(), tmpMatrix);
代码示例来源:origin: ArthurHub/Android-Image-Cropper
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
mAnimRect.left =
mStartCropWindowRect.left
+ (mEndCropWindowRect.left - mStartCropWindowRect.left) * interpolatedTime;
mAnimRect.top =
mStartCropWindowRect.top
+ (mEndCropWindowRect.top - mStartCropWindowRect.top) * interpolatedTime;
mAnimRect.right =
mStartCropWindowRect.right
+ (mEndCropWindowRect.right - mStartCropWindowRect.right) * interpolatedTime;
mAnimRect.bottom =
mStartCropWindowRect.bottom
+ (mEndCropWindowRect.bottom - mStartCropWindowRect.bottom) * interpolatedTime;
mCropOverlayView.setCropWindowRect(mAnimRect);
for (int i = 0; i < mAnimPoints.length; i++) {
mAnimPoints[i] =
mStartBoundPoints[i] + (mEndBoundPoints[i] - mStartBoundPoints[i]) * interpolatedTime;
}
mCropOverlayView.setBounds(mAnimPoints, mImageView.getWidth(), mImageView.getHeight());
for (int i = 0; i < mAnimMatrix.length; i++) {
mAnimMatrix[i] =
mStartImageMatrix[i] + (mEndImageMatrix[i] - mStartImageMatrix[i]) * interpolatedTime;
}
Matrix m = mImageView.getImageMatrix();
m.setValues(mAnimMatrix);
mImageView.setImageMatrix(m);
mImageView.invalidate();
mCropOverlayView.invalidate();
}
代码示例来源:origin: razerdp/FriendCircle
private Rect getDrawableBoundsInView(ImageView iv) {
if (iv != null && iv.getDrawable() != null) {
Drawable d = iv.getDrawable();
Rect result = new Rect();
iv.getGlobalVisibleRect(result);
Rect tDrawableRect = d.getBounds();
Matrix drawableMatrix = iv.getImageMatrix();
float[] values = new float[9];
if (drawableMatrix != null) {
drawableMatrix.getValues(values);
}
result.left += (int) values[2];
result.top += (int) values[5];
result.right = (int) ((float) result.left + (float) tDrawableRect.width() * (values[0] == 0.0F ? 1.0F : values[0]));
result.bottom = (int) ((float) result.top + (float) tDrawableRect.height() * (values[4] == 0.0F ? 1.0F : values[4]));
return result;
} else {
return null;
}
}
}
代码示例来源:origin: fossasia/pslab-android
matrix.set(view.getImageMatrix());
savedMatrix.set(matrix);
start.set(event.getX(), event.getY());
代码示例来源:origin: guolindev/giffun
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
mAnimRect.left =
mStartCropWindowRect.left
+ (mEndCropWindowRect.left - mStartCropWindowRect.left) * interpolatedTime;
mAnimRect.top =
mStartCropWindowRect.top
+ (mEndCropWindowRect.top - mStartCropWindowRect.top) * interpolatedTime;
mAnimRect.right =
mStartCropWindowRect.right
+ (mEndCropWindowRect.right - mStartCropWindowRect.right) * interpolatedTime;
mAnimRect.bottom =
mStartCropWindowRect.bottom
+ (mEndCropWindowRect.bottom - mStartCropWindowRect.bottom) * interpolatedTime;
mCropOverlayView.setCropWindowRect(mAnimRect);
for (int i = 0; i < mAnimPoints.length; i++) {
mAnimPoints[i] =
mStartBoundPoints[i] + (mEndBoundPoints[i] - mStartBoundPoints[i]) * interpolatedTime;
}
mCropOverlayView.setBounds(mAnimPoints, mImageView.getWidth(), mImageView.getHeight());
for (int i = 0; i < mAnimMatrix.length; i++) {
mAnimMatrix[i] =
mStartImageMatrix[i] + (mEndImageMatrix[i] - mStartImageMatrix[i]) * interpolatedTime;
}
Matrix m = mImageView.getImageMatrix();
m.setValues(mAnimMatrix);
mImageView.setImageMatrix(m);
mImageView.invalidate();
mCropOverlayView.invalidate();
}
代码示例来源:origin: martinwithaar/PinchToZoom
/**
* <p>Sets the <code>ImageView</code>. This also sets its inner image matrix as this corrector's matrix automatically.</p>
* @param imageView
*/
public void setImageView(ImageView imageView) {
// TODO Make a weak reference or set to null in order to avoid memory leaks
this.imageView = imageView;
if(imageView != null) {
setMatrix(imageView.getImageMatrix());
}
}
代码示例来源:origin: stackoverflow.com
final ImageView imageView = (ImageView) findViewById(R.id.imageView);
final Matrix matrix = imageView.getImageMatrix();
final float imageWidth = imageView.getDrawable().getIntrinsicWidth();
final int screenWidth = getResources().getDisplayMetrics().widthPixels;
final float scaleRatio = screenWidth / imageWidth;
matrix.postScale(scaleRatio, scaleRatio);
imageView.setImageMatrix(matrix);
代码示例来源:origin: stackoverflow.com
ImageView img = (ImageView)findViewById(R.id.image);
Matrix mtx = img.getImageMatrix();
mtx.setRotate(degrees);
Bitmap bmp = ((BitmapDrawable)img.getDrawable()).getBitmap();
img.setImageBitmap(Bitmap.createBitmap(bmp, 0, 0 , bmp.getWidth(), bmp.getHeight(), mtx, true));
代码示例来源:origin: stackoverflow.com
private float scaleOfImageView(ImageView image) {
float[] coords = new float[]{0, 0, 1, 1};
Matrix matrix = image.getImageMatrix();
matrix.mapPoints(coords);
return coords[2] - coords[0]; //xscale, method assumes maintaining aspect ratio
}
代码示例来源:origin: KingJA/SuperShapeView
private Paint getShaderPaint() {
Bitmap mBitmap = drawableToBitmap(imageView.getDrawable());
BitmapShader mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
Paint mBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mBitmapShader.setLocalMatrix(imageView.getImageMatrix());
mBitmapPaint.setShader(mBitmapShader);
return mBitmapPaint;
}
代码示例来源:origin: stackoverflow.com
ImageView img=(ImageView) rrr.getChildAt(0);
Matrix matrix = new Matrix();
matrix.set(img.getImageMatrix());
matrix.postRotate(90, img.getWidth() / 2, img.getHeight() / 2);
img.setImageMatrix(matrix);
代码示例来源:origin: stackoverflow.com
final float[] getPointOfTouchedCordinate(ImageView view, MotionEvent e) {
final int index = e.getActionIndex();
final float[] coords = new float[] { e.getX(index), e.getY(index) };
Matrix m = new Matrix();
view.getImageMatrix().invert(m);
m.postTranslate(view.getScrollX(), view.getScrollY());
m.mapPoints(coords);
return coords;
}
内容来源于网络,如有侵权,请联系作者删除!