0

在我的应用程序中,用户有机会拍照,然后在 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);
4

1 回答 1

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);
于 2014-05-29T13:50:01.480 回答