title: Limit down scaling of a Bitmap in a SurfaceView, Android
body: <p>im having a single Bitmap in a surfaceview.
  I am using multi touch to handle gestures such as zoom and drag, the problem is that when i scale the bitmap i dont want it to be able to be down scaled that much it wont cover the whole display(surface view). I have found no way to work around this since i cant find a way to get the current downscaled bitmaps current height or width.</p>
  
  <p>Here's some of my code:</p>
  
  <pre><code>private void multiTouchBehavior(MotionEvent event)
  {
      if(event.getAction() == MotionEvent.ACTION_POINTER_2_DOWN)
      {
          _oldDist = spacing(event);
          if(_oldDist &gt; 10f) // just be secure of a bug in the API
          {
              _saved.set(_matrix);
              _mid = midPoint(event);
          }
      }
      else if(event.getAction() == MotionEvent.ACTION_MOVE)
      {
          _newDist = spacing(event);
          if(_newDist &gt; 10f)
          {
               _matrix.set(_saved);
               float scale = _newDist / _oldDist;
  
               _matrix.postScale(scale, scale, _mid.x, _mid.y);                
          }           
      }   
  }
  </code></pre>
  
  <p>And here is what happens in method spacing(event) :</p>
  
  <pre><code>    private float spacing(MotionEvent event) {
         float x = event.getX(0) - event.getX(1);
         float y = event.getY(0) - event.getY(1);
         return FloatMath.sqrt(x * x + y * y);
      }
  </code></pre>
  
  <p>My onDraw(canvas) is just canvas.drawBitmap(myBitmap, _matrix, null) </p>
  
  <p>Anyone know how i could solve this problem?</p>
  
  <p>So just to make sure you get my problem right think of it as a big map of the world that i want to able to zoom in to, and of course zoom out on when iv'e already zoomed in, but NOT allowing it to be out zoomed more than it is at start.</p>