コード例 #1
0
  protected void zoomTo(float scale, float centerX, float centerY) {
    if (scale > mMaxZoom) {
      scale = mMaxZoom;
    }

    float oldScale = getScale();
    float deltaScale = scale / oldScale;

    mSuppMatrix.postScale(deltaScale, deltaScale, centerX, centerY);
    setImageMatrix(getImageViewMatrix());
    center(true, true);
  }
コード例 #2
0
  protected void zoomOut(float rate) {
    if (mBitmapDisplayed.getBitmap() == null) {
      return;
    }

    float cx = getWidth() / 2F;
    float cy = getHeight() / 2F;

    // Zoom out to at most 1x.
    Matrix tmp = new Matrix(mSuppMatrix);
    tmp.postScale(1F / rate, 1F / rate, cx, cy);

    if (getScale(tmp) < 1F) {
      mSuppMatrix.setScale(1F, 1F, cx, cy);
    } else {
      mSuppMatrix.postScale(1F / rate, 1F / rate, cx, cy);
    }
    setImageMatrix(getImageViewMatrix());
    center(true, true);
  }