gpt4 book ai didi

android - 在android中添加水印图片

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:06:21 25 4
gpt4 key购买 nike

我有像这样在图像中添加水印的代码

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.RED);
paint.setAlpha(alpha);
paint.setTextSize(size);
paint.setAntiAlias(true);
paint.setUnderlineText(underline);
canvas.drawText(watermark, location.x, location.y, paint);

return result;
}

然后我用这段代码调用那个函数

mark(bitmap, "watermark", b, null, c, 100, false);
imgshoot.setImageBitmap(bitmap);

但是没有任何反应,你能帮帮我吗??谢谢

最佳答案

它解决了,我只是对该代码稍作改动,感谢你的建议 Doomsknight :)

 public static Bitmap mark(Bitmap src, String watermark) {
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.RED);
paint.setTextSize(18);
paint.setAntiAlias(true);
paint.setUnderlineText(true);
canvas.drawText(watermark, 20, 25, paint);

return result;
}

我用这个函数调用

bitmap = mark(bitmap, "Hallo");
imgshoot.setImageBitmap(bitmap);

关于android - 在android中添加水印图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13266736/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com