Photo turns 90 degress when viewing

74 views Asked by At

In my app the user has the opportunity to take pictures and then view it in an ImageView. The problem is the image when viewing the photo turns 90 dregrees (if i take in portrait it appears in landscape). What am i doing wrong??

Taking photo:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(Environment.getExternalStorageDirectory(), "/PROJETOS/"+nome+"/"+"proj"+id+"_reg"+id_reg+"_"+valor+".jpg");
nome_caminho = "proj"+id+"_reg"+id_reg+"_"+valor+".jpg";
outputFileUri = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, TAKE_PICTURE);   



protected void onActivityResult(int requestCode, int resultCode, Intent data){

    if (requestCode == TAKE_PICTURE){
        mydb.execSQL("INSERT INTO fotos(id_regi,nome,caminho) VALUES('"+id_reg+"','"+nome_caminho+"','"+outputFileUri+"')");

    }

Viewing it:

Options op = new Options();  
    op.inSampleSize = 5;   
    op.inJustDecodeBounds = false;  
    bm = BitmapFactory.decodeFile(caminhoNovo, op); 
    foto.setImageBitmap(bm);
1

There are 1 answers

2
Sripathi On

Just turn it by 90 degree

Matrix matrix=new Matrix();
imageView.setScaleType(ScaleType.MATRIX);   //required
float angle = 90f;//Use your value
matrix.postRotate( angle, imageView.getDrawable().getBounds().width()/2, imageView.getDrawable().getBounds().height()/2);
imageView.setImageMatrix(matrix);