Bitmap添加文字水印

Bitmap添加文字水印

private static Bitmap AddTimeWatermark(Bitmap mBitmap) { //获取原始图片与水印图片的宽与高 int mBitmapWidth = mBitmap.getWidth(); int mBitmapHeight = mBitmap.getHeight(); Bitmap mNewBitmap = Bitmap.createBitmap(mBitmapWidth, mBitmapHeight, Bitmap.Config.ARGB_8888); Canvas mCanvas = new Canvas(mNewBitmap); //向位图中开始画入MBitmap原始图片 mCanvas.drawBitmap(mBitmap,0,0,null); //添加文字 Paint mPaint = new Paint(); String mFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss EEEE").format(new Date()); //String mFormat = TingUtils.getTime()+"\n"+" 纬度:"+GpsService.latitude+"  经度:"+GpsService.longitude; mPaint.setColor(Color.RED); mPaint.setTextSize(20); //水印的位置坐标 mCanvas.drawText(mFormat, (mBitmapWidth * 1) / 10,(mBitmapHeight*14)/15,mPaint); mCanvas.save(Canvas.ALL_SAVE_FLAG); mCanvas.restore(); return mNewBitmap; }

添加了时间的bitmap

www.zeeklog.com  - Bitmap添加文字水印