2016-03-20 19 views
2

カメラの意図から画像を撮影していますが、ポートレートモードで画像を撮っても風景モードになります。画像を回転しようとしているとき:方法を解決できませんmtx.postRotate(int)

これを解決するために、画像を回転させようとしましたが、このエラーが発生しました(下記参照)。

protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    if (requestCode == 1) { 
     int screenWidth = getResources().getDisplayMetrics().widthPixels; 
     int screenHeight = getResources().getDisplayMetrics().heightPixels; 
     File imgFile = new File(pictureImagePath); 
     if(imgFile.exists()){ 
      Bitmap bm = BitmapFactory.decodeFile(imgFile.getAbsolutePath()); 

      //Rotate image 
      if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { 
       // Notice that width and height are reversed 
       Bitmap scaled = ScalingUtilities.createScaledBitmap(bm, screenHeight, screenWidth, ScalingUtilities.ScalingLogic.FIT); 
       int w = scaled.getWidth(); 
       int h = scaled.getHeight(); 
       // Setting post rotate to 90 
       Matrix mtx = new Matrix(); 
       mtx.postRotate(90); //Cannot resolve method 'postRotate(int)' 
       // Rotating Bitmap 
       bm = Bitmap.createBitmap(scaled, 0, 0, w, h, mtx, true); 
      }else{// LANDSCAPE MODE 
       //No need to reverse width and height 
       Bitmap scaled = ScalingUtilities.createScaledBitmap(bm, screenHeight, screenWidth, ScalingUtilities.ScalingLogic.FIT); 
       bm=scaled; 
      } 

      ImageView myImage = (ImageView) findViewById(R.id.imageView); 
      myImage.setImageBitmap(bm); 

     } 
    } 

問題:mtx.postRotate(90);が表示されている:メソッドを解決できません 'postRotate(int型)'

任意の助けを?

気軽に編集を提案してください。どんな助けもありがとうございます。

+0

'Bitmap.createBitmap'のパラメータタイプを参照してください – pskink

+0

@pskinkこれはエラーも表示していますが、それを把握することはできません。あなたは精緻化できますか? –

+0

'Bitmap.createBitmap' 6番目のパラメータ(' Matrix m')をチェックし、それを 'mtx'と比較してください。 – pskink

答えて

3

Bitmap.createBitmapandroid.graphics.Matrixが必要な場合は、android.opengl.Matrixをインポートしている可能性が最も高いです。

これは、コンパイルエラーが発生した理由です。

関連する問題