Android在源图片上的XY坐标再画一个图片

package org.android.iauthor.utils;
/**
 * @author 杨志永
 * Email: [email protected]
 * Date: 2012-9-10
 */
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Bitmap.Config;

public class BitmapUtils 
{
	/**
	 * 
	 * @param sourceBitmap 源图片
	 * @param otherBitmap 要在源图片处画的图片
	 * @param x 在源图片处的x坐标处画otherBitmap
	 * @param y 在源图片处的y坐标处画otherBitmap
	 * @return Bitmap 返回一个新的Bitmap对象
	 */
	public static Bitmap drawBitmapOnSourceBitmap(Bitmap sourceBitmap, Bitmap otherBitmap, int x, int y)
	{
		int sourceBitmapWidth = sourceBitmap.getWidth();
		int sourceBitmapHeight = sourceBitmap.getHeight();
		
		Bitmap resultBitmap = null;
		
		resultBitmap = Bitmap.createBitmap(sourceBitmapWidth, sourceBitmapHeight, Config.ARGB_8888);
		Canvas canvas = new Canvas(resultBitmap);
		
		canvas.drawBitmap(sourceBitmap, 0, 0, null);
		canvas.drawBitmap(otherBitmap, x, y, null);
		return resultBitmap;
	}
}



你可能感兴趣的:(java学习,Anroid学习)