-1

I wanted to rotate the images as much as the user clicks on rotate button.The code below makes the image rotated correctly but my image is becoming blur.

I've been using the code below:

 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

AshAR
  • 228
  • 1
  • 14
Lavanya Velusamy
  • 333
  • 1
  • 6
  • 16
  • Don't rotate the bitmap. Rotate the `ImageView`. – CommonsWare Jan 18 '17 at 13:49
  • 1
    check this links http://stackoverflow.com/questions/28259534/how-to-rotate-image-in-imageview-on-button-click-each-time, http://stackoverflow.com/questions/18016126/when-click-a-button-rotate-image-clockwise-in-android , http://stackoverflow.com/questions/33915142/android-rotate-image-inside-the-button , http://stackoverflow.com/questions/33623291/rotating-image-in-android-with-a-button – AmeeJoshi Jan 18 '17 at 13:50
  • @lavanya lavan : have u found solution for this . Me too facing same problem :( – karthik kolanji May 26 '17 at 11:29

1 Answers1

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);
}
nzala
  • 374
  • 4
  • 10