How might I add a watermark effect to an image in Android?
I found great tutorial on Android Image Processing here.
public static Bitmap mark(Bitmap src, String watermark, Point location, Color color, int alpha, int size, boolean underline) {
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);
Paint paint = new Paint();
paint.setColor(color);
paint.setAlpha(alpha);
paint.setTextSize(size);
paint.setAntiAlias(true);
paint.setUnderlineText(underline);
canvas.drawText(watermark, location.x, location.y, paint);
return result;
}
Thanks to Pete Houston who shares such useful tutorial on basic image processing.
Add Water mark to image in android
it my fault.i found solution to my own problem.Thanks for your answers.i am using wrong bitmap.
in line -
bmp.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
i was using wrong bitmap,that's why it was not working.instead of i have to use
result.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
and after change above line it is work as a charm.
Hope it will help other.
How do i place a water mark image on image that i just took a picture of it in Android?
You can try using any of these jar's in Android.
Im4Java looks most promising.
Adding watermarks to photos
old code:
if ((targetW > 0) || (targetH > 0)) {
scaleFactor = Math.min(photoW/targetW, photoH/targetH);
new code:
if (photoH > IMAGE_MAX_SIZE || photoW> IMAGE_MAX_SIZE) {
scaleFactor = (int)Math.pow(2, (int) Math.round(Math.log(IMAGE_MAX_SIZE / (double) Math.max(photoH, photoW)) / Math.log(0.5)));
then,it works all right.
Related Topics
How to Handle System_Alert_Window Permission Not Being Auto-Granted on Some Pre-Marshmallow Devices
Page Scroll When Soft Keyboard Popped Up
Moving from One Activity to Another Activity in Android
Folder Added on Android Is Not Visible via Usb
Android: Google Maps Location with Low Battery Usage
Playing Local Sound in Phonegap
"Unknown Bits Set in Runtime_Flags: 0X8000" Warning in Logcat on Android Q Emulator
Android Imageview's Onclicklistener Does Not Work
How to Set Searchview Textsize
Check Whether Lock Was Enabled or Not
Clear All Activities in a Task
How to Set an Imageview's Image from a String
Android Support Library Error After Updating to 23.3.0
Opening Infowindow Automatically When Adding Marker Google Maps V2 Android