ya *_*Lya 5 android android-layout
我有代码在这样的图像中添加水印
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;
}
Run Code Online (Sandbox Code Playgroud)
我用这段代码调用该函数
mark(bitmap, "watermark", b, null, c, 100, false);
imgshoot.setImageBitmap(bitmap);
Run Code Online (Sandbox Code Playgroud)
但什么都没发生,你可以帮助我?谢谢
它解决了,我只是改变了一点代码,并感谢你的建议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;
}
Run Code Online (Sandbox Code Playgroud)
我打电话给这个功能
bitmap = mark(bitmap, "Hallo");
imgshoot.setImageBitmap(bitmap);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8832 次 |
| 最近记录: |