मैं फोटो रोटेशन इश्यू कोड के लिए exifInterface का उपयोग कर रहा हूं: कैमरे से कैप्चर की गई छवि अभिविन्यास समस्या का सामना करना।एंड्रॉइड फोन पर कैमरा कैप्चर की गई छवि के साथ अभिविन्यास समस्या का सामना करना
- फ़ाइल से एक बिटमैप बनाएं
Bitmap b = BitmapFactory.decodeFile(imagePath);
- उचित स्तर पर यह स्केलिंग द्वारा बिटमैप का आकार बदलें
int width = b.getWidth();
int height = b.getHeight();
int newWidth = 150;
int newHeight = 150;
float scaleWidth = ((float) newWidth)/width;
float scaleHeight = ((float) newHeight)/height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
// Bitmap resizedBitmap = Bitmap.createBitmap(b, 0, 0, width, height, matrix, true);
// resizedBitmap.compress(Bitmap.CompressFormat.JPEG, 70, out);
- छवि
ExifInterface exif = new ExifInterface(imagePath);
String orientation = exif.getAttribute(ExifInterface.TAG_ORIENTATION);
if (orientation.equals(ExifInterface.ORIENTATION_NORMAL)) {
// Do nothing. The original image is fine.
} else if (orientation.equals(ExifInterface.ORIENTATION_ROTATE_90+"")) {
matrix.postRotate(90);
} else if (orientation.equals(ExifInterface.ORIENTATION_ROTATE_180+"")) {
matrix.postRotate(180);
} else if (orientation.equals(ExifInterface.ORIENTATION_ROTATE_270+"")) {
matrix.postRotate(270);
}
- सहेजें नया बिटमैप के हैंडल उन्मुखीकरण
out = new FileOutputStream(new File("some output file path"));
Bitmap resizedBitmap = Bitmap.createBitmap(b, 0, 0, width, height, matrix, true);
resizedBitmap.compress(Bitmap.CompressFormat.JPEG, 70, out);
संकल्प रोटेशन जारी करने के लिए काम नहीं कर रहा यह कोड, मुझे दिशानिर्देश दे कृपया। एलजी उपकरणों पर यह हमेशा 0 ओरिएंटेशन लौटा रहा है, सैमसंग डिवाइस 6 और 1.
एचटीसी, मोटोरोला, सैमसंग, सोनी और एलजी जैसे सभी उपकरणों के साथ इस समस्या को कैसे ठीक करें।
मैं आप सभी का आभारी हूं कृपया मेरी मदद करें।
क्या आपने एचटीसी पर भी परीक्षण किया था? – user991429
हां, मैं एचटीसी एक्सप्लोरर के साथ ऐप का भी परीक्षण करता हूं और यह एलजी ऑप्टिमस ब्लैक के रूप में ठीक चलता है। @ user991429 – MKJParekh
@MKJParekh: महान काम, धन्यवाद :) – Aerrow