Last active
September 21, 2017 17:33
-
-
Save tank777/caceabc8bd29b252666c2c97a7401b78 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
private Bitmap addWaterMark(Bitmap src, Bitmap waterMark) { | |
if (src == null || waterMark == null) { | |
return null; | |
} | |
try { | |
int w = src.getWidth(); | |
int h = src.getHeight(); | |
Bitmap result = Bitmap.createBitmap(w, h, src.getConfig()); | |
Canvas canvas = new Canvas(result); | |
canvas.drawBitmap(src, 0, 0, null); | |
//int watermarkPadding = 30; | |
int newWatermarkWidth = w / 5; | |
int newWatermarkHeight = (waterMark.getHeight() * newWatermarkWidth) / waterMark.getWidth(); | |
Bitmap newWatermark = Bitmap.createScaledBitmap(waterMark, newWatermarkWidth, newWatermarkHeight, true); | |
canvas.drawBitmap(newWatermark, 0, h - newWatermarkHeight, null); | |
// canvas.drawBitmap(waterMark, 0, 0, null); | |
return result; | |
} catch (Exception ex) { | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment