标签:view cannot translate line alt bitmap draw drawable awb
//加载原图
Bitmap bmSrc = BitmapFactory.decodeResource(getResources(), R.drawable.photo3);
//创建副本
//1.创建与原图一模一样大小的bitmap对象,该对象中目前是没有内容的,可以比喻为创建了和原图一样大小的白纸
Bitmap bmCopy = Bitmap.createBitmap(bmSrc.getWidth(), bmSrc.getHeight(), bmSrc.getConfig());
//2.创建画笔对象
Paint paint = new Paint();
//3.创建画板,把白纸铺到画板上
Canvas canvas = new Canvas(bmCopy);
Matrix mt = new Matrix();
//平移效果,指定平移距离
// mt.setTranslate(20, 10);
//缩放效果,指定缩放比例
// mt.setScale(2, 0.5f, bmCopy.getWidth() / 2, bmCopy.getHeight() / 2);
//旋转效果
// mt.setRotate(45, bmCopy.getWidth() / 2, bmCopy.getHeight() / 2);
//镜面效果
// mt.setScale(-1, 1);
// mt.postTranslate(bmCopy.getWidth(), 0);
//倒影效果
mt.setScale(1, -1);
mt.postTranslate(0, bmCopy.getHeight());
canvas.drawBitmap(bmSrc, mt, paint);
ImageView iv_src = (ImageView) findViewById(R.id.iv_src);
iv_src.setImageBitmap(bmSrc);
ImageView iv_copy = (ImageView) findViewById(R.id.iv_copy);
iv_copy.setImageBitmap(bmCopy);
标签:view cannot translate line alt bitmap draw drawable awb
原文地址:http://www.cnblogs.com/SoulCode/p/6393346.html