Fotoğraf döndürme sorunu kodu için exifInterface kullanıyorum: Fotoğraf makinesinden çekilen fotoğraf yönelimi sorunu.Fotoğraf makinesiyle çekilen fotoğrafın çekilmesiyle ilgili sorunlar Fotoğraf makinelerinde görüntülenen görüntü
Bitmap b = BitmapFactory.decodeFile(imagePath);
- uygun seviyeye ölçekleme ile Bitmap yeniden boyutlandırma dosyasından bir Bitmap Oluştur
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);
-
Görüntünün
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);
}
- kaydet yeni bitmap ait
- Sap yönelimi
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);
çözmek rotasyon sorunu için çalışmıyor Bu kod, bana, rehber verin. Lg aygıtlarında, her zaman 0 yöneliminden dönen exifinterface, Samsung aygıtları 6 ve 1 döndürüyor.
Bu sorunu, htc, Motorola, samsung, Sony ve LG gibi tüm aygıtlarla nasıl düzeltebilirim?
Hepinize minnettarım, lütfen bana yardım edin.
Ayrıca HTC üzerinde test yaptınız mı? – user991429
Evet, uygulamayı HTC Explorer ile de test ediyorum ve LG Optimus Black gibi iyi çalışıyor. @ user991429 – MKJParekh
@MKJParekh: Harika iş, teşekkürler :) – Aerrow