Skip to content

Instantly share code, notes, and snippets.

@davidtavarez
Created April 28, 2014 17:38
Show Gist options
  • Save davidtavarez/11378831 to your computer and use it in GitHub Desktop.
Save davidtavarez/11378831 to your computer and use it in GitHub Desktop.
private static Bitmap getCropBitmap (Bitmap origialBitmap,int left, int top, int right, int bottom){
int targetWidth = right-left;
int targetHeight = bottom-top;
Bitmap cutBitmap = Bitmap.createBitmap(targetWidth,targetHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(cutBitmap);
Rect desRect = new Rect(0, 0, targetWidth, targetHeight);
Rect srcRect = new Rect(left, top, right, bottom);
canvas.drawBitmap(origialBitmap, srcRect, desRect, null);
return cutBitmap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment