Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> android 關於圖片縮放,旋轉的簡單應用

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





  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved