码迷,mamicode.com
首页 > 其他好文 > 详细

使用Martix来实现缩放图片的功能

时间:2014-07-07 16:00:55      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:android   style   blog   color   使用   width   

使用Martix(android.graphics.Matrix)类中的postScale()方法结合Bitmap来实现缩放图片的功能
Bitmap bmp = BitmapFactory.decodeResource(getResource(),R.drawalbe.icon1)
int bmpwidth = bmp.getWidth();
int bmpheight = bmp.getHeight();
Matrix matrix = new Matrix();
matrix.postScale(width,height);
Bitmap bm = Bitmap.createBitmap(bmp,0,0,bmpwidth,bmpheight ,matrix,true);
imageView.setImageBitmap(bm);





iv = (ImageView) findViewById(R.id.iv);
        iv.setImageResource(R.drawable.icon);

onTouchEvent():
Matrix mtrx = iv.getImageMatrix(); 
      mtrx.postScale(2, 2); 
      iv.setImageMatrix(mtrx); 
      iv.setScaleType(ScaleType.MATRIX); 
      iv.invalidate(); 

 

使用Martix来实现缩放图片的功能,布布扣,bubuko.com

使用Martix来实现缩放图片的功能

标签:android   style   blog   color   使用   width   

原文地址:http://www.cnblogs.com/niray/p/3815106.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!