2017-01-18 13 views
-1

ユーザーが回転ボタンをクリックした分だけ画像を回転させたいと思います。下のコードは画像を正しく回転させますが、画像はぼやけています。私は以下のコードを使用してきたビットマップを複数回回転させると画像がぼやけます。

backLayout.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      for(int i=0;i<selectedImageList.size();i++) { 

       BitmapFactory.Options bmOptions = new BitmapFactory.Options(); 
       Bitmap scaledBitmap = BitmapFactory.decodeFile(selectedImageList.get(i), bmOptions); 
       Matrix matrix=new Matrix(); 
       matrix.preRotate(0); 
       Bitmap rotatedBitmap = Bitmap. 
         createBitmap(scaledBitmap , 0, 0, scaledBitmap .getWidth(), scaledBitmap .getHeight(), matrix, true); 

       File file=Utility.createFileFromBitmap(rotatedBitmap); 
       File oldFile=new File(selectedImageList.get(i)); 
       LogUtil.error("Deleted Name",oldFile.getAbsolutePath()+"-->"+file.getAbsolutePath()); 
       oldFile.delete(); 
       itemList.set(selectedImages.get(i),file.getAbsolutePath()); 
       selectedImageList.set(i,file.getAbsolutePath()); 
       mSnapRecyclerAdapter.notifyDataSetChanged(); 


      } 

Below ll be the image

+0

ビットマップを回転させないでください。 'ImageView'を回転させます。 – CommonsWare

+1

このリンクを確認するhttp://stackoverflow.com/questions/28259534/how-to-rotate-image-in-imageview-on-button-click-each-time、http://stackoverflow.com/questions/18016126/ボタンをクリックすると画像が時計回りに表示されます。http://stackoverflow.com/questions/33915142/android-rotate-image-inside-the-button、http://stackoverflow.com/質問/ 33623291 /回転イメージin-a-buttonと – AmeeJoshi

+0

@ラヴァンラヴァン:これのための解決策が見つかりました。私も同じ問題に直面している:( –

答えて

0
Matrix matrix = new Matrix(); 
imageView.setScaleType(ImageView.ScaleType.MATRIX); //required 
matrix.postRotate((float) angle, pivotX, pivotY); 
imageView.setImageMatrix(matrix); 

/

@Override 
public void onClick(View v) 
{     
    imageView.setRotation(imageView.getRotation() + 90); 
} 
関連する問題