Created
August 8, 2018 01:13
-
-
Save chimbori/98750ef9e98f5652f87939a266ca74e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.graphics.Bitmap; | |
import android.graphics.Canvas; | |
import android.graphics.Color; | |
public class BitmapUtils { | |
private BitmapUtils() { | |
} | |
public static Bitmap padBitmap(Bitmap bitmap, int borderSize) { | |
Bitmap bmpWithBorder = Bitmap.createBitmap( | |
bitmap.getWidth() + borderSize * 2, bitmap.getHeight() + borderSize * 2, bitmap.getConfig()); | |
Canvas canvas = new Canvas(bmpWithBorder); | |
canvas.drawColor(Color.TRANSPARENT); | |
canvas.drawBitmap(bitmap, borderSize, borderSize, null); | |
return bmpWithBorder; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment