如何在Android上拍摄照片的图像上放置水印图像?

时间:2011-07-19 08:24:28

标签: java android image-processing watermark

如何在我刚拍摄的照片上放置水印(公司徽标,图像)?

我需要在Android上执行此操作。

你能帮忙吗?

3 个答案:

答案 0 :(得分:4)

您可以将位图绘制到Canvas,并使用Canvas drawText methodsdrawBitmap methods添加文本或图像。例如:

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);

答案 1 :(得分:0)

您可以尝试在Android中使用任何these jar's

Im4Java看起来最有希望。

答案 2 :(得分:0)

试试这个

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