观看时照片旋转90度

时间:2014-05-29 13:43:36

标签: android android-photos

在我的应用中,用户有机会拍摄照片,然后在ImageView中查看。问题是观看照片时的图像变成了90个dregrees(如果我拍摄的是肖像,它会出现在风景中)。我做错了什么?

拍照:

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+"')");

    }

查看它:

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

1 个答案:

答案 0 :(得分:0)

将其旋转90度

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