android - Image rotate 90 degree using camera intent -


Hello I'm working on an Android app where I use the camera intent on the image Need to capture and set bitmap in imageview but here the bitmap rotates 90 degrees. I have examined many threads of stack overflow but have not worked for me.

Here I am executing this exif.getAttributeInt (ExifInterface.TAG_ORIENTATION, 1); Then returning it is no condition in 0 ORIENTATION_UNDEFINED and my getImage function is not satisfactory.

  Intent cameraInventant = new intent (android.provider.MediaStore.ACTION_IMAGE_CAPTURE); Captured Photo Name = System.currentTimeMillis () + ".png"; File photo = new file (environment .getExternalStorage directory (), captureFatName); CameraIntent.putExtra (MediaStore.EXTRA_OUTPUT, Uri.fromFile (Photo)); ImageUri = Uri.framefile (photo); StartActivityForResult (camera entrant, CAMERA_INTENT_REQUEST);   

On-activative result

  Uri selected image = Picture URI; GetContentResolver () Inform (selected image, empty); ContentResolver cr = getContentResolver (); Bitmap bitmap; {Try bitmap = android.provider.MediaStore.Images.Media.getBitmap (cr, selected image); Bitmap = Util.getImage (bitmap, selected IMAGE.toString ()); mPictureImageView.setImageBitmap (bitmap); } Hold (exception e) {Log.e ("new point activity", e.ostustring ()); } / ** * Image Orientation * * @ Ultimate ImagePath * @ Return Orientation Angle * @ Thraise IOException * / Public Static Bitmap IGJ (bitmap bitmap, string path) throws IOException {matrix M = node matrix ()); ExifInterface exif = new ExifInterface (path); Int Orientation = EXIF ​​.getAttributeInt (ExifInterface.TAG_ORIENTATION, 1); If ((Orientation == ExifInterface.ORIENTATION_ROTATE_180)) {m.postRotate (180); Bitmap = bitmap.quoteetmap (bitmap, 0, 0, bitmap .getWidth (), bitmap.gatehite (), m, true); Return bitmap; } And if (Orientation == ExifInterface.ORIENTATION_ROTATE_90) {m.postRotate (90); Bitmap = bitmap.quoteetmap (bitmap, 0, 0, bitmap .getWidth (), bitmap.gatehite (), m, true); Return bitmap; } And if (Orientation == ExifInterface.ORIENTATION_ROTATE_270) {m.postRotate (270); Bitmap = bitmap.quoteetmap (bitmap, 0, 0, bitmap .getWidth (), bitmap.gatehite (), m, true); Return bitmap; } Return Bitmap; }    

I have applied a photo taking action that you can take pictures And you can set orientation. This Samsung Galaxy galaxy, Tablet, Sony Xperia Series, Tablet tablet, has been tested for every device.

You can see your accepted response to the rotation of images on this topic:

If you need to save and use that image Savings function:

  Public Zero save photos (bitmap BMP) {imageFileFolder} = New file (environment getExternalStorageDirectory (), cc.getDirectoryName ()); ImageFileFolder.mkdir (); FileOutputStream Out = Null; Calendar c = Calendar.getInstance (); String date = IIT (Cd. MONTH) + IITT (C.GATE (calendar DAY_OF_MONTH)) + IITT (C.Gate (calendar.IEER)) + IITT (C Gate (HORRUYY)) + From IITT (CAGAT (CalendarMINUEE) + IITT (CGAT (Calendar. SCND)); ImageFileName = new file (imageFileFolder, date.toString () + ".jpg"); {Out} Try new FileOutputStream (imageFileName); Bmp.compress (bitmap.compress format.jpg, 70, out); Out.flush (); Out.close (); ScanPhoto (imageFileName.toString ()); Out = null; } Hold (exception e) {e.printStackTrace (); }}   

ScanFoto Function:

  Public Zero ScanFoto (Last String ImageFilename) {geniusPath = imageFileName; MsConn = New MediaConnection Connection (MyClass.this, New MediaConnection Connection component) {Media Connected on Public Zero () {msConn.scanFile (imageFileName, null);} @ Override Scanning on Zero (String Path, Uri Uri) {msConn. Disconnect ();}}); MsConn.connect (); }   

SavePhotoTask class:

  class SavePhotoTask asyncTask and lt; Byte [], string, string & gt; {@Override protected string doInBackground (byte [...] JPEG) Photo of file = new file (Environment Tag ExportStyle Directory ("," photo.jpg "); If (photo.exists ()) {photo.delete (); } {FileOutputStream fos = new FileOutputStream (try photo.getPath ()); Fos.write (jpeg [0]); Fos.close (); } Hold (java.io.IOException e) {} return (empty); }}    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -