android中给图片击水印 java

分类:手机开发| 发布:佚名| 查看: | 发表时间:2014/1/7

android中给图片打水印

 

/**	 * 	 * @param src 原图片	 * @param watermark  要打的水印图片	 * @return Bitmap 打好水印的图片	 */	private Bitmap createBitmap(Bitmap src,Bitmap watermark){		if(src == null){			return null;		}		int srcWidth = src.getWidth();		int srcHeight = src.getHeight();				int waterWidth = watermark.getWidth();		int waterHeight = watermark.getHeight();		//create the new blank bitmap		Bitmap newb = Bitmap.createBitmap(srcWidth,srcHeight,Config.ARGB_8888);//创建一个新的和src长度宽度一样的位图		Canvas cv = new Canvas(newb);		cv.drawBitmap(src, 0, 0,null);//在0,0坐标开始画入src		/*Paint paint = new Paint();		paint.setColor(Color.RED);*/		if(watermark != null){			cv.drawBitmap(watermark, srcWidth-waterWidth,srcHeight-waterHeight, null);//在src的右下解画入水印图片			//cv.drawText("HELLO",srcWidth-waterWidth,srcHeight-waterHeight, paint);//这是画入水印文字,在画文字时,需要指定paint		}		cv.save(Canvas.ALL_SAVE_FLAG);//保存		cv.restore();//存储		return newb;	}

 


 

365据说看到好文章不转的人,服务器容易宕机
原创文章如转载,请注明:转载自郑州网建-前端开发 http://camnpr.com/
本文链接:http://camnpr.com/mobile-dev/832.html