Question

J'ai une application qui prend une photo et affiche l'image sur un Imageview. Le problème est, je ne peux prendre une photo en mode paysage pour que le bmp à afficher dans le bon sens - Y at-il une manière que je peux tourner à droite en haut si la photo est prise en mode portrait /

Merci!

Voici le code que j'utilise pour placer l'image dans la vue img -

  private void processCameraImage(Intent intent) {
    setContentView(R.layout.detectlayout);
    ((Button) findViewById(R.id.detect_face)).setOnClickListener(btnClick);

    ImageView imageView = (ImageView) findViewById(R.id.image_view);

    cameraBitmap = (Bitmap) intent.getExtras().get("data");

    imageView.setImageBitmap(cameraBitmap);

Il y a un bouton visages détecter qui détecte s'il y a des visages présents.

Était-ce utile?

La solution

Voici comment vous tourner un bmp:

   private Bitmap rotateImage(Bitmap b, float angle)
   {
      //create a new empty bitmap to hold rotated image
       Bitmap returnBitmap = new Bitmap(b.Width, b.Height);
       //make a graphics object from the empty bitmap
       Graphics g = Graphics.FromImage(returnBitmap);
       //move rotation point to center of image
       g.TranslateTransform((float)b.Width/2,(float)b.Height / 2);
       //rotate
       g.RotateTransform(angle);
       //move image back
       g.TranslateTransform(-(float)b.Width/2,-(float)b.Height / 2);
    }

Autres conseils

Voici le code je onActivityResult () dans mon activité. Le but était de retour pour en choisissant une image de l'image / * Type. Fonctionne bien pour moi!

Uri imageUri = intent.getData();
                String[] orientationColumn = {MediaStore.Images.Media.ORIENTATION};
                Cursor cur = managedQuery(imageUri, orientationColumn, null, null, null);
                int orientation = -1;
                if (cur != null && cur.moveToFirst()) {
                    orientation = cur.getInt(cur.getColumnIndex(orientationColumn[0]));
                }  
                Matrix matrix = new Matrix();
                matrix.postRotate(orientation);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top