android - 如何在 Android 中为图像添加水印效果?

标签 android image watermark

我有一张带边框的图片,我需要添加水印效果。我该怎么做?

最佳答案

我找到了关于 Android 图像处理的精彩教程 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;
}

感谢 Pete Houston 分享了有关基本图像处理的有用教程。

关于android - 如何在 Android 中为图像添加水印效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10679445/

相关文章:

java - 单击按钮后在弹出窗口中显示图像 - Android/Java

python - 如何从 OpenCV 中的 alpha channel 创建掩码?

.net - 检测图像/视频中的水印/ Logo

android:id 加号是什么

android - 这是在 android 中设置模拟位置的最佳应用程序

Android Studio 在编译 android 库(aar)时包含远程库

android - 如何在 Android 上将语音转换为电话?

安卓 : Image qulity decreased using ImageLoader

python - 如何使用 opencv python 从汽车后视摄像头拍摄的视频中删除线条?

FFmpeg如何在过滤器复合体上添加drawtext以及水印和调色板