hackp0int
hackp0int

Reputation: 4161

How do i place a water mark image on image that i just took a picture of it in Android?

How do I place a water mark (company logo, image) on an picture I've just taken?

I need to do it on Android.

Can you please help?

Upvotes: 4

Views: 9109

Answers (3)

Sukhesh Chukkapalli
Sukhesh Chukkapalli

Reputation: 205

Try this

  public static Bitmap mark(Bitmap src) {
    int w = src.getWidth();
    int h = src.getHeight();
    int pw=w-170;
    int ph=h-170;
    Bitmap result = Bitmap.createBitmap(w, h, src.getConfig());
    Canvas canvas = new Canvas(result);
    Bitmap resized = Bitmap.createScaledBitmap(src, 150, 150, true);

    canvas.drawBitmap(src, 0, 0, null);
    Paint paint = new Paint();
    paint.setColor(Color.TRANSPARENT);
    paint.setAlpha(50);
    paint.setTextSize(20);
    paint.setAntiAlias(true);
    paint.setUnderlineText(false);
    canvas.drawBitmap(resized,pw,ph,paint);
    return result;
    }

Upvotes: 1

Dan Osipov
Dan Osipov

Reputation: 1431

You can draw the bitmap to a Canvas, and use the Canvas drawText methods or drawBitmap methods to add text or image. Ex:

drawingCache = Bitmap.createBitmap(300, 400, Bitmap.Config.ARGB_8888);

Canvas canvas = new Canvas(drawingCache);
Paint paint = new Paint();

// Draw your bitmap to the canvas
canvas.drawBitmap(bitmap, 0, 0, paint);

Paint watermarkPaint = new Paint();
watermarkPaint.setColor(Color.WHITE);
watermarkPaint.setAlpha(150);
watermarkPaint.setTextSize(30);
watermarkPaint.setTextAlign(Paint.Align.LEFT);
watermarkPaint.setFlags(Paint.ANTI_ALIAS_FLAG);

canvas.drawText("Watermark", 100, 100, watermarkPaint);

Upvotes: 4

Reno
Reno

Reputation: 33792

You can try using any of these jar's in Android.

Im4Java looks most promising.

Upvotes: 0

Related Questions