title: Crop Bitmap using RectF parameters on Android
body: <p>Using MikeOrtiz's <a href="https://github.com/MikeOrtiz/TouchImageView" rel="nofollow">awesome ImageView implementation</a> with touch and zoom events, I wanted to crop a picture taken with the camera to match the zoom. Using his method...</p>
  
  <pre><code>// Return a Rect representing the zoomed image.
  RectF getZoomedRect();
  </code></pre>
  
  <p>...I tried cropping the resulting picture bitmap to the zoom size like so:</p>
  
  <pre><code>RectF zoomCoordinates = mTouchImageView.getZoomedRect();
  
  Bitmap croppedBitmapToOverview = Bitmap.createBitmap(
                  AppResources.sCurrentImage,
                  ((int) zoomCoordinates.left),
                  ((int) zoomCoordinates.top),
                  ((int) zoomCoordinates.width()),
                  ((int) zoomCoordinates.height()));
  </code></pre>
  
  <p>However I get a "must be bigger than 0" error with this. While debugging I noticed ALL values were 0 due to casting to an Integer. The real values however go something like this:</p>
  
  <pre><code>//Log.d print for each of those fields without the int cast
  Left 0.34047672
  Top 0.20797288
  Width 0.33333334
  Height 0.3429547
  </code></pre>
  
  <p>So there's my problem, but I can't see how to fix this. I've never worked with bitmaps before or canvas, Rect, etc.</p>
  
  <p>Is there some tweaking I could do to these values, or should I take a different approach altogether?</p>