protected void zoomToPoint(float scale, float pointX, float pointY) {
    float cx = getWidth() / 2F;
    float cy = getHeight() / 2F;

    panBy(cx - pointX, cy - pointY);
    zoomTo(scale, cx, cy);
  }
 @Override
 public boolean onKeyUp(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK && event.isTracking() && !event.isCanceled()) {
     if (getScale() > 1.0f) {
       // If we're zoomed in, pressing Back jumps out to show the
       // entire image, otherwise Back returns the user to the gallery.
       zoomTo(1.0f);
       return true;
     }
   }
   return super.onKeyUp(keyCode, event);
 }
  protected void zoomTo(float scale) {
    float cx = getWidth() / 2F;
    float cy = getHeight() / 2F;

    zoomTo(scale, cx, cy);
  }