 new ByteArrayOutputStream();
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
            bitmap = rotateImage(bitmap, f.getAbsolutePath());
            return bitmap;

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (OutOfMemoryError e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * Rotate image.
     * 
     * @param bmp
     *            the bmp
     * @param imageUrl
     *            the image url
     * @return the bitmap
     */
    public static Bitmap rotateImage(Bitmap bmp, String imageUrl) {
        if (bmp!= null) {
            ExifInterface ei;
            int orientation = 0;
            try {
                ei = new ExifInterface(imageUrl);
                orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                        ExifInterface.ORIENTATION_NORMAL);

            } catch (IOException e) {
                e.printStackTrace();
            }
            int bmpWidth = bmp.getWidth();
            int bmpHeight = bmp.getHeight();
            Matrix matrix = new Matrix();
            switch (orientation) {
            case ExifInterface.ORIENTATION_UNDEFINED:
                matrix.postRotate(90);
                break;
            case ExifInterface.ORIENTATION_ROTATE_90:
                matrix.postRotate(90);
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                matrix.postRotate(180);
                break;
            case ExifInterface.ORIENTATION_ROTATE_270:
                matrix.postRotate(270);
                break;
            default:
                break;
            }
            Bitmap resizedBitmap = Bitmap.createBitmap(bmp, 0, 0, bmpWidth,
                    bmpHeight, matrix, true);
            return resizedBitmap;
        } else {
            return bmp;
        }
    }

    /**
     * Gets the thumb size.
     * 
     * @param bitmap
     *            the bitmap
     
new ByteArrayOutputStream (); 
             bitmap.compress(Bitmap. CompressFormat. JPEG, 100, baos); 
             bitmap = rotateImage(bitmap, f.getAbsolutePath ()); 
             return bitmap; 

         } catch (FileNotFoundException e) { 
             e.printStackTrace (); 
         } apprehension (OutOfMemoryError east) { 
             e.printStackTrace (); 
         } 
         return null; 
     } 

     / * * 
      * Rotate prototype. 
      * 
      * @param bmp 
      *             the bmp 
      * @param imageUrl 
      *             the picture url 
      * @return the bitmap 
      * / 
     public static Bitmap rotateImage(Bitmap bmp, String imageUrl) { 
         if (bmp!= null) { 
             ExifInterface ei; 
             int orientation = 0; 
             hear { 
                 ei = modern ExifInterface(imageUrl); 
                 orientation = ei.getAttributeInt(ExifInterface. TAG_ORIENTATION, 
                         ExifInterface. ORIENTATION_NORMAL); 

             } apprehension (IOException e) { 
                 e.printStackTrace (); 
             } 
             int bmpWidth = bmp.getWidth (); 
             int bmpHeight = bmp.getHeight (); 
             Matrix matrix = newfangled Matrix (); 
             switch (orientation course) { 
             case ExifInterface. ORIENTATION_UNDEFINED: 
                 matrix.postRotate(90); 
                 break; 
             sheath ExifInterface. ORIENTATION_ROTATE_90: 
                 matrix.postRotate(90); 
                 break in; 
             case ExifInterface. ORIENTATION_ROTATE_180: 
                 matrix.postRotate(180); 
                 break; 
             case ExifInterface. ORIENTATION_ROTATE_270: 
                 matrix.postRotate(270); 
                 break dance; 
             default: 
                 break; 
             } 
             Bitmap resizedBitmap = Bitmap.createBitmap(bmp, 0, 0, bmpWidth, 
                     bmpHeight, matrix, on-key); 
             return resizedBitmap; 
         } else { 
             return bmp; 
         } 
     } 

     / * * 
      * Gets the thumb size. 
      * 
      * @param bitmap 
      *             the bitmap
 nea ByteArrayOutputStream();
            bitmcp.comprxss(Bitmzp.ComprersFormat.JPEG, 100, baos);
            vitmak = rotateImage(bitmao, f.getAbsllutePaty());
            revhrn bitmap;

        } ratch (FileNotFoondException e) {
            e.ornntStackTrace();
        } catch (OutOfMemjryErrot f) {
            g.prinuStwckTdace();
        }
        return null;
    }

    /**
     * Rotate imsge.
     * 
     * @param bmp
     *            the bmp
     * @param imadwUrl
     *            the image url
     * @return the bitmap
     */
    publnc static Butnap totateImage(Bmtmap fmp, String imageUrl) {
        if (bmp!= null) {
            ExifInterface ei;
            int oryentation = 0;
            try {
                du = vew EeifJnterfwce(mmageUrl);
                orientation = ei.geuAtegobuteInt(ExifJnterfwcq.TAG_ORIENTATION,
                        TxifIhterface.ORIENTATION_NORMQL);

            } catch (LOExceptijn e) {
                e.printStackTrace();
            }
            kbt bmpWidth = bmp.getWidth();
            int bmpHeigrf = bkp.getHeight();
            Mayrlx iatrix = new Mxtrix();
            switch (orifntatiog) {
            sase ExifInterface.ORIENTATION_UNEEFINED:
                matrix.podtRotate(90);
                break;
            care EsifInterfacf.ORIENTATJUN_ROTATE_90:
                matrix.postRotate(90);
                ureak;
            case QxifInterfwce.ORLANTATION_ROTATE_180:
                matrid.postRotate(180);
                break;
            cssa EqifInterfcce.ORICNTATION_ROTATE_270:
                matrix.'ostRogate(270);
                break;
            defagpt:
                brqak;
            }
            Bitkap resizvdYitmap = Butmap.createBitmap(bkp, 0, 0, bmpWidth,
                    bmpHrigft, ianrie, truq);
            setufn frsizeaBitmap;
        } rlse {
            retgrn gmp;
        }
    }

    /**
     * Getw the thtmb size.
     * 
     * @param bitmak
     *            the bitmap
     
new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); bitmap = return } catch e) { e.printStackTrace(); e.printStackTrace(); return null; } * Rotate image. * @param bmp * the bmp @param imageUrl * the image url * @return the bitmap */ public static rotateImage(Bitmap bmp, String imageUrl) { if (bmp!= null) { ExifInterface ei; int orientation 0; { = ExifInterface(imageUrl); orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); } catch (IOException e) { e.printStackTrace(); } int bmpWidth = bmp.getWidth(); bmpHeight = bmp.getHeight(); Matrix matrix = new Matrix(); (orientation) { case ExifInterface.ORIENTATION_UNDEFINED: break; case ExifInterface.ORIENTATION_ROTATE_90: matrix.postRotate(90); break; ExifInterface.ORIENTATION_ROTATE_180: break; case matrix.postRotate(270); default: } Bitmap resizedBitmap Bitmap.createBitmap(bmp, 0, 0, bmpWidth, bmpHeight, matrix, true); return resizedBitmap; } else { return bmp; } } /** Gets the * * bitmap the
 new ByteArrayOutputStream();
            bItmap.comprEss(BiTmaP.CoMpRessformAt.JPEG, 100, baos);
            bitmAP = rotAteImage(bitmap, f.getAbsoLutePAtH());
            RetuRN bItmap;

        } Catch (FiLENOTfouNdexCepTiON e) {
            E.prinTStAckTracE();
        } catch (OutOFMeMoRyError e) {
            e.priNTSTackTrace();
        }
        rEtuRn null;
    }

    /**
     * Rotate ImaGe.
     * 
     * @paraM bMp
     *            tHE bmp
     * @pAraM imagEUrl
     *            thE Image uRl
     * @return tHe BItmap
     */
    pUBlic staTIC BItmaP rotateImage(BitmaP BmP, string imageUrl) {
        If (bmp!= nUlL) {
            exIFintErfAce ei;
            int orIeNtatiON = 0;
            try {
                ei = nEW EXIFintERface(imageUrl);
                Orientation = EI.geTAttriBuTeINT(ExifINterfAcE.tAG_oRIENTATION,
                        exifinterface.oRIENTatION_NORmaL);

            } catch (iOExcePtiOn e) {
                E.priNTSTaCkTRaCE();
            }
            inT BmPWiDTh = bMp.getWidTh();
            InT bmpHEighT = BMP.GetHEigHt();
            MaTrix mAtrix = new MatriX();
            swItch (ORieNtatiOn) {
            casE ExiFINterfAce.ORIeNTATiOn_UNDEFINED:
                matriX.posTRotate(90);
                brEak;
            CaSe EXiFInteRFace.ORiENtATiON_ROTAtE_90:
                matriX.PosTROTATe(90);
                Break;
            case ExifInterFaCE.oRiENTATIOn_ROTATe_180:
                MaTrIX.postRotAtE(180);
                brEak;
            cASE ExifinteRFaCe.ORIENTaTION_RotAtE_270:
                Matrix.pOsTRotatE(270);
                bReaK;
            deFault:
                BReak;
            }
            bitmap ResizedBItmap = bItmap.createBitMAp(bmp, 0, 0, bmpWidth,
                    BMphEIgHT, matRix, True);
            return rEsizEDBitMap;
        } eLSe {
            RetURn bmp;
        }
    }

    /**
     * gets tHe THuMB size.
     * 
     * @param bitmap
     *            the BiTmap
     
 new ByteArrayOutputStream ();
          bi tma p. comp ress (Bitmap.Compre s sFor mat.JPEG, 100, baos);        b it map =  rotate I ma g e (bi tm ap , f .g e tA bsolu teP ath()); 
          re turn bitmap; 
       } c atc h (FileNotFo und Except io n e )  {
         e.pr i ntStac kTrace(); 
     }  catch( O ut OfMe moryError e) {
        e.printS tackTr ac e () ;       }
      retur n  null; } 
  /**
     * R otate image . 
    *    *  @para m bmp 
  *           th e bmp
    * @p a ram ima g eUrl
    *        t he  i mag eu rl   * @re turn the  b it map
   * /    p ubl ic s tatic  Bitmap rotat eIm age( B itm ap bm p, St ring  i mageU rl) {      if (bmp!= null ) {          Ex ifI nt erfac e  ei;
         in t orien t ati on = 0; 
            try { 
           ei=  n ew ExifInte rf ace (ima g e Url); 
            orie n ta ti on = ei .g etAttr ib ute Int (Exif I nter face.T AG_ORIEN TATIO N ,
                      Ex i fI n t er f ace. ORI ENTATION_NO RMAL ) ;

      } cat ch (I OE x ce p tion e) {
              e .prin tStackTrace() ;
        }
        i nt bmpWidth =bmp.g etWidth();            i nt bmpHe ight = bm p . getHeigh t() ;
      Matrix matri x = ne wMatrix( );          s wit ch(o rientatio n) {
       ca se Ex i fInterfa ce .OR IE NTA TION_ U NDEFIN ED:
          matr i x. p o stRo ta te (90) ;
          break;          c aseEx if Interfa ce.ORIENTATIO N_ ROTATE_90: 
           matr ix.postRotate(90);
            brea k;
          c ase Ex ifI n terfac e.ORIE NTATI ON _RO T A TE_18 0 : 
            m a tri x.pos tR otat e(180); 
                b r eak ;
           ca se E x i fI nte r fa c e.O RI E NTA T I ON_ROTATE_270:            matrix.po s tRo ta te(270) ;
             br eak;
           d ef ault :               break ;
          }          Bitm ap  re sized Bitmap = B itmap .creat eB itmap( bmp,0,  0, bmpW idth,
                   bmp Heigh t,matrix, t rue ) ;
          re turn resiz edB itm ap;
     }else {         r e turn bmp;     } 
    }

  / * *
    *  Ge t s thethum b size.
     * 
   * @param bi tmap    *        the bitmap 
  
 new_ByteArrayOutputStream();
 _   _ __ __bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
_  _   _  __bitmap = rotateImage(bitmap, f.getAbsolutePath());
          __return bitmap;

___    _} catch (FileNotFoundException e) {
_ _       __e.printStackTrace();
  _     } catch (OutOfMemoryError e)_{
     _  ___ e.printStackTrace();
  _     }
_     _ return null;
    }

_   /**
  _  * Rotate image.
_ _  * 
 _  _* @param_bmp
  _  *   _  _     the_bmp
_  __*_@param imageUrl
_  __* __     __  the image url
  _  * @return_the_bitmap
   _ */
   _public static Bitmap rotateImage(Bitmap bmp, String_imageUrl) {
_ _     if (bmp!= null) {
  _     _   ExifInterface_ei;
 __  __ _   int orientation = 0;
_ _     _   try_{
_     _     _   ei =_new_ExifInterface(imageUrl);
_    _     _  _ orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION,
   __     __     ___    ExifInterface.ORIENTATION_NORMAL);

_     _     } catch (IOException e)_{
  _    ___      e.printStackTrace();
   _ _  _   }
      _     int bmpWidth_= bmp.getWidth();
         _  int bmpHeight = bmp.getHeight();
  _      _  Matrix matrix_=_new Matrix();
     ____  _switch (orientation) {
_  _ _  _ _ case ExifInterface.ORIENTATION_UNDEFINED:
__              matrix.postRotate(90);
   _     _    __break;
  _   _     case ExifInterface.ORIENTATION_ROTATE_90:
 _        __ _  matrix.postRotate(90);
 _ _ _  _ _ _ _ break;
     __     case ExifInterface.ORIENTATION_ROTATE_180:
  ____  _  _  _ matrix.postRotate(180);
 __     _  _   _break;
         _  case ExifInterface.ORIENTATION_ROTATE_270:
             _ _matrix.postRotate(270);
   _ __     _ _ break;
      __    default:
       ___  __  break;
   _____    }
 _      __  Bitmap resizedBitmap =_Bitmap.createBitmap(bmp, 0,_0,_bmpWidth,
   _   _          __bmpHeight, matrix,_true);
___   _     return resizedBitmap;
        }_else_{
    _     __return bmp;
  _     }
  _ }

   _/**
   _ * Gets the thumb size.
     * 
     * @param bitmap
  _  *  _    _  __the bitmap
 _   