本文介绍了添加水印图像中的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有code添加水印的图像像这样
I have code to add watermark in image like this
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;
}
和我称这个code的作用
and I call that function with this code
mark(bitmap, "watermark", b, null, c, 100, false);
imgshoot.setImageBitmap(bitmap);
但没有发生,u能帮助我吗?谢谢
but nothing happen , can u help me ?? thanks
推荐答案
它解决了,我只是改变了乌拉圭回合的建议Doomsknight小为code和感谢:)
it solved , I just change little for that code , and thanks for ur advice 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!