Java 类android.graphics.Matrix.ScaleToFit 实例源码

项目:boohee_v5.6    文件:SelectableRoundedImageView.java   
private void configureBounds(Canvas canvas) {
    Rect clipBounds = canvas.getClipBounds();
    Matrix canvasMatrix = canvas.getMatrix();
    if (ScaleType.CENTER == this.mScaleType) {
        this.mBounds.set(clipBounds);
    } else if (ScaleType.CENTER_CROP == this.mScaleType) {
        applyScaleToRadii(canvasMatrix);
        this.mBounds.set(clipBounds);
    } else if (ScaleType.FIT_XY == this.mScaleType) {
        Matrix m = new Matrix();
        m.setRectToRect(this.mBitmapRect, new RectF(clipBounds), ScaleToFit.FILL);
        this.mBitmapShader.setLocalMatrix(m);
        this.mBounds.set(clipBounds);
    } else if (ScaleType.FIT_START == this.mScaleType || ScaleType.FIT_END == this
            .mScaleType || ScaleType.FIT_CENTER == this.mScaleType || ScaleType
            .CENTER_INSIDE == this.mScaleType) {
        applyScaleToRadii(canvasMatrix);
        this.mBounds.set(this.mBitmapRect);
    } else if (ScaleType.MATRIX == this.mScaleType) {
        applyScaleToRadii(canvasMatrix);
        this.mBounds.set(this.mBitmapRect);
    }
}
项目:material-components-android    文件:FloatingActionButtonImpl.java   
private void calculateImageMatrixFromScale(float scale, Matrix matrix) {
  matrix.reset();

  Drawable drawable = view.getDrawable();
  if (drawable != null && maxImageSize != 0) {
    // First make sure our image respects mMaxImageSize.
    RectF drawableBounds = tmpRectF1;
    RectF imageBounds = tmpRectF2;
    drawableBounds.set(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    imageBounds.set(0, 0, maxImageSize, maxImageSize);
    matrix.setRectToRect(drawableBounds, imageBounds, ScaleToFit.CENTER);

    // Then scale it as requested.
    matrix.postScale(scale, scale, maxImageSize / 2f, maxImageSize / 2f);
  }
}
项目:FMTech    文件:HeroGraphicView.java   
public final void onLoaded(FifeImageView paramFifeImageView, Bitmap paramBitmap)
{
  this.mIsImageLoaded = true;
  if (!this.mIsFrozenInCorpusFill) {
    this.mHeroImageView.setVisibility(0);
  }
  if ((this.mShouldTopAlignImage) && (paramBitmap != null))
  {
    int i = paramBitmap.getWidth();
    int j = paramBitmap.getHeight();
    int k = this.mHeroImageView.getWidth();
    float f = j / i;
    Matrix localMatrix = new Matrix();
    RectF localRectF = new RectF(0.0F, 0.0F, i, j);
    int m = (int)(f * k);
    localMatrix.setRectToRect(localRectF, new RectF(0.0F, 0.0F, k, m), Matrix.ScaleToFit.FILL);
    this.mHeroImageView.setScaleType(ImageView.ScaleType.MATRIX);
    this.mHeroImageView.setImageMatrix(localMatrix);
  }
}
项目:ZoomableView    文件:ZoomViewTouchable.java   
private void restoreInitialPosition() {
    // Will start animation for the image to return in its bounds
    updateDiffRect();
    if (rectMap.width() < getWidth()) {
        rectMapUpdate.offset(-rectMap.centerX() + rectView.centerX(), 0);
    } else if (rectMap.left > 0) {
        rectMapUpdate.offset(-rectMap.left, 0);
    } else if (rectMap.right < getWidth()) {
        rectMapUpdate.offset(getWidth() - rectMap.right, 0);
    }

    if (rectMap.height() < getHeight()) {
        rectMapUpdate.offset(0, -rectMap.centerY() + rectView.centerY());
    } else if (rectMap.top > 0) {
        rectMapUpdate.offset(0, -rectMap.top);
    } else if (rectMap.bottom < getHeight()) {
        rectMapUpdate.offset(0, getHeight() - rectMap.bottom);
    }

    if (!equalsRect(rectMapUpdate, rectMap)) {
        // Create matrix for translation from current rect to new rect
        matrixTranslate.setRectToRect(rectMapOrigin, rectMapUpdate, ScaleToFit.FILL);
        mapScaleAnim = new ZoomScaleAnim(matrix, matrixTranslate, 200);
        startZoomAnimation();
    }
}
项目:letv    文件:RoundedBitmapDisplayer.java   
protected void onBoundsChange(Rect bounds) {
    super.onBoundsChange(bounds);
    this.mRect.set((float) this.margin, (float) this.margin, (float) (bounds.width() - this.margin), (float) (bounds.height() - this.margin));
    Matrix shaderMatrix = new Matrix();
    shaderMatrix.setRectToRect(this.mBitmapRect, this.mRect, ScaleToFit.FILL);
    this.bitmapShader.setLocalMatrix(shaderMatrix);
}
项目:boohee_v5.6    文件:RoundedBitmapDisplayer.java   
protected void onBoundsChange(Rect bounds) {
    super.onBoundsChange(bounds);
    this.mRect.set((float) this.margin, (float) this.margin, (float) (bounds.width() -
            this.margin), (float) (bounds.height() - this.margin));
    Matrix shaderMatrix = new Matrix();
    shaderMatrix.setRectToRect(this.mBitmapRect, this.mRect, ScaleToFit.FILL);
    this.bitmapShader.setLocalMatrix(shaderMatrix);
}
项目:boohee_v5.6    文件:CircleBitmapDisplayer.java   
protected void onBoundsChange(Rect bounds) {
    super.onBoundsChange(bounds);
    this.mRect.set(0.0f, 0.0f, (float) bounds.width(), (float) bounds.height());
    this.radius = (float) (Math.min(bounds.width(), bounds.height()) / 2);
    this.strokeRadius = this.radius - (this.strokeWidth / 2.0f);
    Matrix shaderMatrix = new Matrix();
    shaderMatrix.setRectToRect(this.mBitmapRect, this.mRect, ScaleToFit.FILL);
    this.bitmapShader.setLocalMatrix(shaderMatrix);
}
项目:okwallet    文件:ScannerView.java   
public void setFraming(final Rect frame, final RectF framePreview, final int displayRotation,
        final int cameraRotation, final boolean cameraFlip) {
    this.frame = frame;
    matrix.setRectToRect(framePreview, new RectF(frame), ScaleToFit.FILL);
    matrix.postRotate(-displayRotation, frame.exactCenterX(), frame.exactCenterY());
    matrix.postScale(cameraFlip ? -1 : 1, 1, frame.exactCenterX(), frame.exactCenterY());
    matrix.postRotate(cameraRotation, frame.exactCenterX(), frame.exactCenterY());

    invalidate();
}
项目:FMTech    文件:FifeImageView.java   
private void updateMatrix()
{
  Drawable localDrawable = getDrawable();
  float f1 = getWidth();
  float f2 = getHeight();
  if ((localDrawable == null) || (f1 == 0.0F) || (f2 == 0.0F)) {
    return;
  }
  float f3 = localDrawable.getIntrinsicWidth();
  float f4 = localDrawable.getIntrinsicHeight();
  if ((f3 <= 0.0F) || (f4 <= 0.0F)) {
    this.mMatrix.reset();
  }
  for (;;)
  {
    super.setImageMatrix(this.mMatrix);
    return;
    float f5 = Math.max(f1 / f3, f2 / f4);
    float f6 = Math.max(f3 - f1 / f5, 0.0F);
    float f7 = Math.max(f4 - f2 / f5, 0.0F);
    float f8 = f6 * this.mFocusPoint.x;
    float f9 = f6 - f8;
    float f10 = f7 * this.mFocusPoint.y;
    float f11 = f7 - f10;
    float f12 = f3 * (this.mDefaultZoom - 1.0F);
    float f13 = f4 * (this.mDefaultZoom - 1.0F);
    RectF localRectF1 = new RectF(f8 + f12 / 2.0F, f10 + f13 / 2.0F, f3 - f9 - f12 / 2.0F, f4 - f11 - f13 / 2.0F);
    RectF localRectF2 = new RectF(0.0F, 0.0F, f1, f2);
    this.mMatrix.setRectToRect(localRectF1, localRectF2, Matrix.ScaleToFit.FILL);
  }
}
项目:ZoomableView    文件:ZoomView.java   
private void resetOrigin() {
    if (rectView.isEmpty()) {
        matrixOrigin.reset();
    } else {
        matrixOrigin.setRectToRect(rectMapOrigin, rectView, ScaleToFit.CENTER);
        matrixOrigin.getValues(matrixOriginValues);
    }
}
项目:FMTech    文件:BaseOrchestrationFragment.java   
protected final View onCreateThemedView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle)
{
  View localView = paramLayoutInflater.inflate(this.mRootLayout, paramViewGroup, false);
  this.mMainContent = ((FocusedViewToTopScrollView)localView.findViewById(R.id.main_content));
  this.mTitleImageView = ((FifeNetworkImageView)localView.findViewById(R.id.title_image));
  this.mTopBarView = ((TopBarView)localView.findViewById(R.id.top_bar));
  this.mTitleSeparator = localView.findViewById(R.id.title_separator);
  this.mButtonBar = ((ButtonBar)localView.findViewById(R.id.button_bar));
  this.mButtonBar.setPositiveButtonOnClickListener(this);
  this.mButtonBar.setNegativeButtonOnClickListener(this);
  this.mButtonBar.setExpandButtonOnClickListener(this);
  String str = this.mArguments.getBundle("additionalArgs").getString("com.google.android.wallet.orchestration.TITLE_IMAGE_FIFE_URL");
  if (!TextUtils.isEmpty(str))
  {
    this.mTitleImageView.setOnLoadedListener(new FifeNetworkImageView.OnLoadedListener()
    {
      public final void onLoaded$70e9aa75(Bitmap paramAnonymousBitmap)
      {
        int i;
        int j;
        int k;
        int m;
        float f;
        int n;
        if (paramAnonymousBitmap != null)
        {
          BaseOrchestrationFragment.this.mTitleImageView.setScaleType(ImageView.ScaleType.MATRIX);
          i = BaseOrchestrationFragment.this.mTitleImageView.getWidth();
          j = BaseOrchestrationFragment.this.mTitleImageView.getHeight();
          k = paramAnonymousBitmap.getWidth();
          m = paramAnonymousBitmap.getHeight();
          f = k / m;
          if (!BaseOrchestrationFragment.this.getResources().getBoolean(R.bool.wallet_uic_is_tablet)) {
            break label156;
          }
          n = (int)(f * j);
        }
        for (int i1 = j;; i1 = Math.max(j, (int)(i / f)))
        {
          RectF localRectF1 = new RectF(0.0F, 0.0F, k, m);
          RectF localRectF2 = new RectF(0.0F, 0.0F, n, i1);
          Matrix localMatrix = new Matrix();
          localMatrix.setRectToRect(localRectF1, localRectF2, Matrix.ScaleToFit.FILL);
          BaseOrchestrationFragment.this.mTitleImageView.setImageMatrix(localMatrix);
          return;
          label156:
          n = Math.max(i, (int)(f * j));
        }
      }
    });
    this.mTitleImageView.setVisibility(0);
    this.mTitleImageView.setFadeIn(false);
    this.mTitleImageView.setFifeImageUrl(str, PaymentUtils.getImageLoader(getActivity().getApplicationContext()), ((Boolean)G.images.useWebPForFife.get()).booleanValue());
  }
  this.mTopInfoText = ((ImInfoMessageTextView)localView.findViewById(R.id.top_info_text));
  this.mTopInfoText.setParentUiNode(this);
  this.mTopInfoText.setUrlClickListener(this);
  this.mProgressTopBarView = ((TopBarView)localView.findViewById(R.id.progress_top_bar));
  this.mProgressBar = ((ProgressBar)localView.findViewById(R.id.progress_bar));
  this.mProgressText = ((TextView)localView.findViewById(R.id.progress_text));
  this.mErrorText = ((TextView)localView.findViewById(R.id.message));
  this.mErrorCode = ((TextView)localView.findViewById(R.id.details));
  updateNonSubformPageUi();
  this.mSubFormFragment = ((FormFragment)getChildFragmentManager().findFragmentById(R.id.sub_form_holder));
  if (this.mSubFormFragment == null) {
    updateSubFormFragment();
  }
  for (;;)
  {
    if ((paramBundle != null) && (this.mInlineErrorMessageDetails != null)) {
      updateInlineErrorMessageStateAndVisibility();
    }
    localView.findViewById(R.id.steal_focus_and_hide_keyboard).setOnFocusChangeListener(this);
    return localView;
    configureAutoScrollingForPage();
    constructAndConfigureDependencyGraphManagerForPage();
  }
}
项目:FMTech    文件:MediaView.java   
private final void c(int paramInt1, int paramInt2)
{
  int i1 = getPaddingTop();
  int i2 = getPaddingRight();
  int i3 = getPaddingBottom();
  int i4 = getPaddingLeft();
  int i5 = getWidth() - i4 - i2;
  int i6 = getHeight() - i1 - i3;
  float f1 = paramInt1 / paramInt2;
  float f2 = i5 / i6;
  switch (this.w)
  {
  }
  for (;;)
  {
    this.aj.set(this.ag);
    this.ai.set(this.ah);
    this.ak.setRectToRect(this.aj, this.ai, Matrix.ScaleToFit.FILL);
    if (!this.ak.invert(this.al)) {
      this.al.reset();
    }
    return;
    this.ag.set(0, 0, paramInt1, paramInt2);
    if (f1 > f2)
    {
      int i11 = (i6 - (int)(i5 / f1)) / 2;
      this.ah.set(i4, i1 + i11, i5 + i4, i1 + i6 - i11);
    }
    else
    {
      int i10 = (i5 - (int)(f1 * i6)) / 2;
      this.ah.set(i4 + i10, i1, i5 + i4 - i10, i6 + i1);
      continue;
      if (f1 > f2)
      {
        int i9 = (paramInt1 - (int)(f2 * paramInt2)) / 2;
        this.ag.set(i9, 0, paramInt1 - i9, paramInt2);
      }
      for (;;)
      {
        this.ah.set(i4, i1, i5 + i4, i6 + i1);
        break;
        int i7 = (int)(paramInt1 / f2);
        int i8 = Math.max((int)(paramInt2 * this.N) - i7 / 2, 0);
        this.ag.set(0, i8, paramInt1, i7 + i8);
      }
      this.ag.set(0, 0, paramInt1, paramInt2);
      this.ah.set(0, 0, i5, i6);
    }
  }
}