title: IllegalArgumentException: x + width must be <= bitmap.width() in android
body: <p>I  want  to crop an image with in a margin (10,50,10,50),(left,top,right,bottom) respectively of an imageview. Here is my code</p>
  
  <pre><code>Bitmap bitmap = Bitmap.createBitmap(imgView.getWidth(),imgView.getHeight(), Bitmap.Config.ARGB_8888);
  
  Bitmap result = Bitmap.createBitmap(bitmap, (imgView.getLeft() + 10),
                  imgView.getTop() + 50,imgView.getRight() - 10,imgView.getBottom() - 50);
  bitmap.recycle();
  Canvas canvas = new Canvas(result);
  imgView.draw(canvas);
  </code></pre>
  
  <p>ie, if my imageview is of dimension 200X300.then i want to get the bitmap image with in the specified area only .When I am trying to do this It shows error</p>
  
  <pre><code> FATAL EXCEPTION: main
   java.lang.IllegalArgumentException: x + width must be &lt;= bitmap.width()
      at android.graphics.Bitmap.createBitmap(Bitmap.java:410)
      at android.graphics.Bitmap.createBitmap(Bitmap.java:383)
      at android.view.View.performClick(View.java:2485)
      at android.view.View$PerformClick.run(View.java:9080)
      at android.os.Handler.handleCallback(Handler.java:587)
      at android.os.Handler.dispatchMessage(Handler.java:92)
      at android.os.Looper.loop(Looper.java:130)
      at android.app.ActivityThread.main(ActivityThread.java:3687)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:507)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
      at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>How can i solve this?</p>
  
  <p>Thanks</p>