How Might I Add a Watermark Effect to an Image in Android

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



Leave a reply



Submit