package com.backfire.graphics;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;

import com.backfire.doudizhu.common.CriticalPool;

/**   
 * @Title: PCanvas.java
 * @Description: 管理适配的canvas
 * @author Potter
 * @date 2013年10月23日 下午9:09:51
 * @version V2.0   
 */
public class PCanvas extends Canvas{
	
	public PCanvas(){
		super();
	}
	
	public PCanvas(Bitmap bufferImg) {
		super(bufferImg);
	}
	
	public void drawBitmap(Bitmap bitmap,int scaleToW,int scaleToH,float x,float y,Paint paint){
		int resW = bitmap.getWidth();
        int resH = bitmap.getHeight();
        
        float sx= scaleToW/(float)resW;
        float sy= scaleToH/(float)resH;
       
		Matrix matrix = CriticalPool.getMatrix();
		matrix.setScale(sx,sy);
		matrix.postTranslate(x,y);
		
		super.drawBitmap(bitmap, matrix, null);
	}
	
}
