जब मैं गैलरी से एंड्रॉइड एप्लिकेशन में अपने इमेजव्यू पर सेट करने के लिए एक छवि चुनता हूं तो मुझे लगता है कि यह 180 या 270 या 90 डिग्री से उलटा हुआ है।
तो इसे जांचने/हल करने के लिए मैंने EXIF
उन्मुखीकरण का उपयोग किया, लेकिन यह हमेशा मुझे "0" देता है।गैलरी ओरिएंटेशन से चुनी गई एंड्रॉइड छवि हमेशा 0 है: Exif TAG
मैं समस्या क्या प्राप्त करने में सक्षम नहीं हूं।
कोड:
Uri selectedImageUri = data.getData();
absolutePath = selectedImageUri.getPath();
exifMedia = new ExifInterface(absolutePath);
String exifOrint = exifMedia.getAttribute(ExifInterface.TAG_ORIENTATION);
exifOrientation = Integer.parseInt(exifOrint);
System.out.println("Orientation Tag is:"+exifOrientation);
/** Convert URI into byte */
ContentResolver cr = getBaseContext()
.getContentResolver();
InputStream inputStream = cr
.openInputStream(selectedImageUri);
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
rotatedBMP = getResizedBitmapImage(
bitmap, 100, 100,exifOrientation);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
rotatedBMP.compress(Bitmap.CompressFormat.PNG, 100,
stream);
byteArray = stream.toByteArray();
mimProfileImageBrowse.setImageBitmap(rotatedBMP);
विधि:
public Bitmap getResizedBitmapImage(Bitmap bm, int newHeight, int newWidth, int exifOrientation) {
int width = bm.getWidth();
int height = bm.getHeight();
float scaleWidth = ((float) newWidth)/width;
float scaleHeight = ((float) newHeight)/height;
/**
* create a matrix for the manipulation
*/
Matrix matrix = new Matrix();
/**
* resize the bit map
*/
/*
1 = Horizontal (normal)
2 = Mirror horizontal
3 = Rotate 180
4 = Mirror vertical
5 = Mirror horizontal and rotate 270 CW
6 = Rotate 90 CW
7 = Mirror horizontal and rotate 90 CW
8 = Rotate 270 CW
*/
switch (exifOrientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
break;
case ExifInterface.ORIENTATION_TRANSPOSE:
rotate = 45;
break;
default:
break;
}
matrix.postScale(scaleWidth, scaleHeight);
matrix.postRotate(rotate);
/**
* recreate the new Bitmap
*/
Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
resizedBitmap = Bitmap.createScaledBitmap(bm, 65, 65, true);
return resizedBitmap;
}
कृपया मदद करते हैं। matrix.postROTATE
बिटमैप्स घूर्णन नहीं कर रहा है। मुझे नहीं पता क्यों।
धन्यवाद
मैंने EXIF समस्या हल कर दी है। क्या आप कृपया जांच सकते हैं कि बिटमैप घूर्णन क्यों नहीं कर रहा है। यह सभी लाइनों को सही ढंग से निष्पादित कर रहा है लेकिन यह बिटमैप –
को घुमा नहीं रहा है मैंने यह भी किया है। अब घूर्णन। धन्यवाद –
क्या आप मुझे बता सकते हैं कि "MAX_IMAGE_DIMENSION" क्या है? – Dhrupal