首页 > 代码库 > android 关于图片缩放,旋转的简单应用

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





android 关于图片缩放,旋转的简单应用