/*
添加全屏斜着45度的文字
/
public static Bitmap drawCenterLable(Context context, Bitmap bmp, String text) {
float scale = context.getResources().getDisplayMetrics().density;
//创建一样大小的图片
Bitmap newBmp = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), Config.ARGB_8888);
//创建画布
Canvas canvas = new Canvas(newBmp);
canvas.drawBitmap(bmp, 0, 0, null); //绘制原始图片
canvas.save();
canvas.rotate(45); //顺时针转45度
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.argb(50, 255, 255, 255)); //白色半透明
paint.setTextSize(100 scale);
paint.setDither(true);
paint.setFilterBitmap(true);
Rect rectText = new Rect(); //得到text占用宽高, 单位:像素
paint.getTextBounds(text, 0, text.length(), rectText);
double beginX = (bmp.getHeight()/2 - rectText.width()/2) * 1.4; //45度角度值是1.414
double beginY = (bmp.getWidth()/2 - rectText.width()/2) * 1.4;
canvas.drawText(text, (int)beginX, (int)beginY, paint);
canvas.restore();
return newBmp;
}
long begin = System.currentTimeMillis();
Bitmap destBmp = ImageUtil.drawCenterLable(this, sourBitmap, "某某公司专用");
long end = System.currentTimeMillis();
Log.d("brycegao", "打水印用时:" + (end-begin) + "毫秒");
mWartermarkImage.setImageBitmap(destBmp);
java.lang.OutOfMemoryError: Failed to allocate a 467251212 byte allocation with 16767536 free bytes and 110MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:613)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:446)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:469)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:501)
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有