List of usage examples for android.graphics Matrix getValues
public void getValues(float[] values)
From source file:cn.jmessage.android.uikit.pickerimage.view.BaseZoomableImageView.java
protected float getValue(Matrix matrix, int whichValue) { matrix.getValues(mMatrixValues); return mMatrixValues[whichValue]; }
From source file:com.jsibbold.zoomage.ZoomageView.java
/** * Animate the matrix back to its original position after the user stopped interacting with it. *///from ww w. j a v a2s .co m private void animateToStartMatrix() { final Matrix beginMatrix = new Matrix(getImageMatrix()); beginMatrix.getValues(mValues); //difference in current and original values final float xsdiff = startValues[Matrix.MSCALE_X] - mValues[Matrix.MSCALE_X]; final float ysdiff = startValues[Matrix.MSCALE_Y] - mValues[Matrix.MSCALE_Y]; final float xtdiff = startValues[Matrix.MTRANS_X] - mValues[Matrix.MTRANS_X]; final float ytdiff = startValues[Matrix.MTRANS_Y] - mValues[Matrix.MTRANS_Y]; ValueAnimator anim = ValueAnimator.ofFloat(0, 1f); anim.addUpdateListener(new AnimatorUpdateListener() { final Matrix activeMatrix = new Matrix(getImageMatrix()); final float[] values = new float[9]; @Override public void onAnimationUpdate(ValueAnimator animation) { float val = (Float) animation.getAnimatedValue(); activeMatrix.set(beginMatrix); activeMatrix.getValues(values); values[Matrix.MTRANS_X] = values[Matrix.MTRANS_X] + xtdiff * val; values[Matrix.MTRANS_Y] = values[Matrix.MTRANS_Y] + ytdiff * val; values[Matrix.MSCALE_X] = values[Matrix.MSCALE_X] + xsdiff * val; values[Matrix.MSCALE_Y] = values[Matrix.MSCALE_Y] + ysdiff * val; activeMatrix.setValues(values); setImageMatrix(activeMatrix); } }); anim.setDuration(RESET_DURATION); anim.start(); }
From source file:baizhuan.hangzhou.com.gankcopy.view.customview.photoview.PhotoViewAttacher.java
/** * Helper method that 'unpacks' a Matrix and returns the required value * * @param matrix - Matrix to unpack/* w w w. ja v a 2 s . co m*/ * @param whichValue - Which value from Matrix.M* to return * @return float - returned value */ private float getValue(Matrix matrix, int whichValue) { matrix.getValues(mMatrixValues); return mMatrixValues[whichValue]; }
From source file:android.support.transition.ChangeTransform.java
private ObjectAnimator createTransformAnimator(TransitionValues startValues, TransitionValues endValues, final boolean handleParentChange) { Matrix startMatrix = (Matrix) startValues.values.get(PROPNAME_MATRIX); Matrix endMatrix = (Matrix) endValues.values.get(PROPNAME_MATRIX); if (startMatrix == null) { startMatrix = MatrixUtils.IDENTITY_MATRIX; }/*from w w w . ja v a 2 s .c om*/ if (endMatrix == null) { endMatrix = MatrixUtils.IDENTITY_MATRIX; } if (startMatrix.equals(endMatrix)) { return null; } final Transforms transforms = (Transforms) endValues.values.get(PROPNAME_TRANSFORMS); // clear the transform properties so that we can use the animation matrix instead final View view = endValues.view; setIdentityTransforms(view); final float[] startMatrixValues = new float[9]; startMatrix.getValues(startMatrixValues); final float[] endMatrixValues = new float[9]; endMatrix.getValues(endMatrixValues); final PathAnimatorMatrix pathAnimatorMatrix = new PathAnimatorMatrix(view, startMatrixValues); PropertyValuesHolder valuesProperty = PropertyValuesHolder.ofObject(NON_TRANSLATIONS_PROPERTY, new FloatArrayEvaluator(new float[9]), startMatrixValues, endMatrixValues); Path path = getPathMotion().getPath(startMatrixValues[Matrix.MTRANS_X], startMatrixValues[Matrix.MTRANS_Y], endMatrixValues[Matrix.MTRANS_X], endMatrixValues[Matrix.MTRANS_Y]); PropertyValuesHolder translationProperty = PropertyValuesHolderUtils.ofPointF(TRANSLATIONS_PROPERTY, path); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(pathAnimatorMatrix, valuesProperty, translationProperty); final Matrix finalEndMatrix = endMatrix; AnimatorListenerAdapter listener = new AnimatorListenerAdapter() { private boolean mIsCanceled; private Matrix mTempMatrix = new Matrix(); @Override public void onAnimationCancel(Animator animation) { mIsCanceled = true; } @Override public void onAnimationEnd(Animator animation) { if (!mIsCanceled) { if (handleParentChange && mUseOverlay) { setCurrentMatrix(finalEndMatrix); } else { view.setTag(R.id.transition_transform, null); view.setTag(R.id.parent_matrix, null); } } ViewUtils.setAnimationMatrix(view, null); transforms.restore(view); } @Override public void onAnimationPause(Animator animation) { Matrix currentMatrix = pathAnimatorMatrix.getMatrix(); setCurrentMatrix(currentMatrix); } @Override public void onAnimationResume(Animator animation) { setIdentityTransforms(view); } private void setCurrentMatrix(Matrix currentMatrix) { mTempMatrix.set(currentMatrix); view.setTag(R.id.transition_transform, mTempMatrix); transforms.restore(view); } }; animator.addListener(listener); AnimatorUtils.addPauseListener(animator, listener); return animator; }
From source file:com.example.PagerCoverFlow.PagerContainer.java
private void transformImageBitmap(ImageView child, Matrix imageMatrix, int rotationAngle) { mCamera.save();//ww w .j av a 2 s.com // final Matrix imageMatrix = t.getMatrix();; final int imageHeight = child.getLayoutParams().height; final int imageWidth = child.getLayoutParams().width; final int rotation = Math.abs(rotationAngle); // mCamera.translate(0.0f, 0.0f, 100.0f); Log.i("Select", "imageWidth:" + imageWidth + " " + "imageHeight:" + imageHeight); //As the angle of the view gets less, zoom in // if ( rotation < mMaxRotationAngle ) { float zoomAmount = (float) (mMaxZoom + (rotation * 1.5)); Log.i("Select", "rotation:" + rotation + " zoomAmount:" + zoomAmount); mCamera.translate(0.0f, 0.0f, zoomAmount); } //Alpha int alphaVal = 255 - rotation * 3; // child.setAlpha(alphaVal); //[0,255] child.getDrawable().setAlpha(alphaVal); // mCamera.rotateY(rotationAngle); mCamera.getMatrix(imageMatrix); imageMatrix.preTranslate(-(imageWidth / 2), -(imageHeight / 2)); imageMatrix.postTranslate((imageWidth / 2), (imageHeight / 2)); mCamera.restore(); float[] values = new float[9]; imageMatrix.getValues(values); float globalX = values[Matrix.MTRANS_X]; float globalY = values[Matrix.MTRANS_Y]; // float width = values[Matrix.MSCALE_X]*CommonValue.menuWidth ; // float height = values[Matrix.MSCALE_Y]*CommonValue.menuWidth; values[Matrix.MSCALE_X] = 2; values[Matrix.MSCALE_Y] = 2; imageMatrix.setValues(values); }
From source file:com.android.volley.ui.PhotoView.java
/** * Helper method that 'unpacks' a Matrix and returns the required value * * @param matrix - Matrix to unpack/*from w w w.j a v a 2s . c o m*/ * @param whichValue - Which value from Matrix.M* to return * @return float - returned value */ private float getValue(Matrix matrix, int whichValue) { matrix.getValues(mValues); return mValues[whichValue]; }
From source file:com.android.launcher2.AsyncTaskCallback.java
private boolean beginDraggingWidget(View v) { mDraggingWidget = true;// w w w . j a va 2s . co m // Get the widget preview as the drag representation ImageView image = (ImageView) v.findViewById(R.id.widget_preview); PendingAddItemInfo createItemInfo = (PendingAddItemInfo) v.getTag(); // If the ImageView doesn't have a drawable yet, the widget preview hasn't been loaded and // we abort the drag. if (image.getDrawable() == null) { mDraggingWidget = false; return false; } // Compose the drag image Bitmap preview; Bitmap outline; float scale = 1f; if (createItemInfo instanceof PendingAddWidgetInfo) { // This can happen in some weird cases involving multi-touch. We can't start dragging // the widget if this is null, so we break out. if (mCreateWidgetInfo == null) { return false; } PendingAddWidgetInfo createWidgetInfo = mCreateWidgetInfo; createItemInfo = createWidgetInfo; int spanX = createItemInfo.spanX; int spanY = createItemInfo.spanY; int[] size = mLauncher.getWorkspace().estimateItemSize(spanX, spanY, createWidgetInfo, true); FastBitmapDrawable previewDrawable = (FastBitmapDrawable) image.getDrawable(); float minScale = 1.25f; int maxWidth, maxHeight; maxWidth = Math.min((int) (previewDrawable.getIntrinsicWidth() * minScale), size[0]); maxHeight = Math.min((int) (previewDrawable.getIntrinsicHeight() * minScale), size[1]); preview = getWidgetPreview(createWidgetInfo.componentName, createWidgetInfo.previewImage, createWidgetInfo.icon, spanX, spanY, maxWidth, maxHeight); // Determine the image view drawable scale relative to the preview float[] mv = new float[9]; Matrix m = new Matrix(); m.setRectToRect(new RectF(0f, 0f, (float) preview.getWidth(), (float) preview.getHeight()), new RectF(0f, 0f, (float) previewDrawable.getIntrinsicWidth(), (float) previewDrawable.getIntrinsicHeight()), Matrix.ScaleToFit.START); m.getValues(mv); scale = (float) mv[0]; } else { PendingAddShortcutInfo createShortcutInfo = (PendingAddShortcutInfo) v.getTag(); Drawable icon = mIconCache.getFullResIcon(createShortcutInfo.shortcutActivityInfo); preview = Bitmap.createBitmap(icon.getIntrinsicWidth(), icon.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); mCanvas.setBitmap(preview); mCanvas.save(); renderDrawableToBitmap(icon, preview, 0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight()); mCanvas.restore(); mCanvas.setBitmap(null); createItemInfo.spanX = createItemInfo.spanY = 1; } // Don't clip alpha values for the drag outline if we're using the default widget preview boolean clipAlpha = !(createItemInfo instanceof PendingAddWidgetInfo && (((PendingAddWidgetInfo) createItemInfo).previewImage == 0)); // Save the preview for the outline generation, then dim the preview outline = Bitmap.createScaledBitmap(preview, preview.getWidth(), preview.getHeight(), false); // Start the drag mLauncher.lockScreenOrientation(); mLauncher.getWorkspace().onDragStartedWithItem(createItemInfo, outline, clipAlpha); mDragController.startDrag(image, preview, this, createItemInfo, DragController.DRAG_ACTION_COPY, null, scale); outline.recycle(); preview.recycle(); return true; }