4

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?

whostolemyhat
  • 3,107
  • 4
  • 34
  • 50
hackp0int
  • 4,052
  • 8
  • 59
  • 95

3 Answers3

4

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);
Dan Osipov
  • 1,429
  • 12
  • 15
1

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;
    }
0

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

Im4Java looks most promising.

Community
  • 1
  • 1
Reno
  • 33,594
  • 11
  • 89
  • 102
  • That doesn't work, i want to use it in Android SDK, not a java application, i think it would be obvious? – hackp0int Jul 19 '11 at 09:36
  • 3
    Did you even try? [Here is how to add an external jar to and android application](http://www.youtube.com/watch?v=eY_uqi_qIz0) – Reno Jul 19 '11 at 09:51
  • I have followed after the instructions and i still not able to use the Thumbnails.of(...) i receive this error: The type java.awt.image.BufferedImage cannot be resolved. It is indirectly referenced from required .class files – hackp0int Jul 19 '11 at 10:13
  • This is the error i receive: The type java.awt.image.BufferedImage cannot be resolved. It is indirectly referenced from required .class files – hackp0int Jul 21 '11 at 04:50