Używam kodu podobnego do tego na tym blogu http://blog.logichigh.com/2008/06/05/uiimage-fix/ , aby obracać obrazy po wykonaniu ich aparatem iPhone. Używam AVFoundation
.UIImage Orientacja, gdy iPhone jest na osi Z
Mam ekstrakcji odpowiedni kod tutaj:
case UIImageOrientationUp: //EXIF = 1
transform = CGAffineTransformIdentity;
break;
case UIImageOrientationUpMirrored: //EXIF = 2
transform = CGAffineTransformMakeTranslation(imageSize.width, 0.0);
transform = CGAffineTransformScale(transform, -1.0, 1.0);
break;
case UIImageOrientationDown: //EXIF = 3
transform = CGAffineTransformMakeTranslation(imageSize.width, imageSize.height);
transform = CGAffineTransformRotate(transform, M_PI);
break;
case UIImageOrientationDownMirrored: //EXIF = 4
transform = CGAffineTransformMakeTranslation(0.0, imageSize.height);
transform = CGAffineTransformScale(transform, 1.0, -1.0);
break;
case UIImageOrientationLeftMirrored: //EXIF = 5
boundHeight = bounds.size.height;
bounds.size.height = bounds.size.width;
bounds.size.width = boundHeight;
transform = CGAffineTransformMakeTranslation(imageSize.height, imageSize.width);
transform = CGAffineTransformScale(transform, -1.0, 1.0);
transform = CGAffineTransformRotate(transform, 3.0 * M_PI/2.0);
break;
case UIImageOrientationLeft: //EXIF = 6
boundHeight = bounds.size.height;
bounds.size.height = bounds.size.width;
bounds.size.width = boundHeight;
transform = CGAffineTransformMakeTranslation(0.0, imageSize.width);
transform = CGAffineTransformRotate(transform, 3.0 * M_PI/2.0);
break;
case UIImageOrientationRightMirrored: //EXIF = 7
boundHeight = bounds.size.height;
bounds.size.height = bounds.size.width;
bounds.size.width = boundHeight;
transform = CGAffineTransformMakeScale(-1.0, 1.0);
transform = CGAffineTransformRotate(transform, M_PI/2.0);
break;
case UIImageOrientationRight: //EXIF = 8
boundHeight = bounds.size.height;
bounds.size.height = bounds.size.width;
bounds.size.width = boundHeight;
transform = CGAffineTransformMakeTranslation(imageSize.height, 0.0);
transform = CGAffineTransformRotate(transform, M_PI/2.0);
break;
Działa to dobrze, gdy telefon jest utrzymywana na osi X
lub Y
.
Jednak, gdy trzymam telefon na osi Z
. Zawsze pokazuje, że UIImage
ma EXIF = 2
.
Wiem, że mogę użyć przyspieszeniomierza, aby stwierdzić, kiedy urządzenie znajduje się na osi Z
. Jednak nie widzę ścieżki, która doprowadzi mnie do rozróżnienia zdjęć zrobionych, z tym oznaczonym, ponieważ wszystkie one nadal mają EXIF = 2
.
tj. Pozwoli mi to rozróżnić zdjęcia wykonane na Z. Ale nie pozwoli mi to na odróżnienie samych zdjęć, np. Pejzaż1 (Przycisk Home po lewej stronie, Portret, Pejzaż2 (przycisk Home po prawej)
Jaką wersję ios używasz? –
Telefon, na którym testuję, ma iOS 6. –
Czy możliwe jest użycie żyroskopu? –