当前位置: 代码迷 >> Android >> android 关于图片缩放,旋转的容易应用
  详细解决方案

android 关于图片缩放,旋转的容易应用

热度:75   发布时间:2016-04-28 03:00:18.0
android 关于图片缩放,旋转的简单应用

右转

private void right() {		// TODO Auto-generated method stub		int bmpW = bm.getWidth() ; 		int bmpH = bm.getHeight() ;		double scale =1 ;		scaleW = (float)(scaleW*scale);        scaleH = (float)(scaleH*scale);        Matrix mt =new Matrix ();        	mt .postScale(scaleW, scaleH);         	        mt.setRotate(curDegrees=curDegrees+5);        Bitmap bitmap= Bitmap.createBitmap(bm, 0, 0, bmpW, bmpH, mt, true);        iv.setImageBitmap(bitmap);	}
左转 

 

private void left() {		int bmpW = bm.getWidth() ; 		int bmpH = bm.getHeight() ;		double scale =1 ;		scaleW = (float)(scaleW*scale);        scaleH = (float)(scaleH*scale);        Matrix mt =new Matrix ();        	mt .postScale(scaleW, scaleH);         mt.setRotate(curDegrees=curDegrees-5);        Bitmap bitmap= Bitmap.createBitmap(bm, 0, 0, bmpW, bmpH, mt, true);        iv.setImageBitmap(bitmap);	}
缩小 

private void small() {        int width  =bm.getWidth() ;         int height = bm.getHeight() ;        double  scale = 0.8;        scaleW= (float) (scale*scaleW) ;		scaleH = (float) (scaleH*scale) ;		Matrix mt =new Matrix ();  		mt.postScale(scaleW, scaleH);		Bitmap resizebmp = Bitmap.createBitmap(bm,0,0,width,height,mt,true); 		iv.setImageBitmap(resizebmp);			}

放大 

private void big() {		 int bmpW = bm.getWidth() ; 		 int bmpH = bm.getHeight() ;		 double scale =1.25 ; 		 scaleW = (float) (scaleW*scale) ; 		 scaleH = (float) (scaleH * scale) ;		 Matrix mt = new Matrix () ; 		 mt.postScale(scaleW, scaleH) ;		 Bitmap bmp = Bitmap.createBitmap(bm, 0, 0, bmpW, bmpH, mt, true) ;		 iv.setImageBitmap(bmp);	}





  相关解决方案