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);
	}





郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。