2015-09-02 109 views
0

我有一個應用程序,我需要拍一張照片,然後通過繪製它來製作png圖層。我的png層絕對正確,並具有橫向維度。如何在橫向模式下拍攝照片[iOS8]?

但是當我上傳拍攝的照片時,它具有縱向尺寸。

- (void)takePhoto { 
    AVCaptureConnection *videoConnection = nil; 
    for (AVCaptureConnection *connection in StillImageOutput.connections) { 
     for (AVCaptureInputPort *port in [connection inputPorts]) { 
      if ([[port mediaType] isEqual:AVMediaTypeVideo]) { 
       videoConnection = connection; 
       break; 
      } 
     } 
    } 
    [StillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) { 
     if (imageDataSampleBuffer != NULL) { 
      NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer]; 
      UIImage *image = [UIImage imageWithData:imageData]; 

      UIImage *ipadImage = [self imageRotatedByDegrees:image deg:0]; 

      NSLog(@"image orientation: %ld", (long)image.imageOrientation); 
      NSLog(@"image width: %f , height: %f", image.size.width, image.size.height); 

      captured.image = ipadImage; 

謝謝你的幫忙!

+0

考慮接受有用的答案。 要接受答案,請點擊最佳答案旁邊的空白複選標記,這樣做會增加您的聲望並提供更多功能,請參閱[聲譽常見問題](http://stackoverflow.com/faq#reputation)請參閱[這個頁面](http://meta.stackoverflow.com/questions/5234/how-does-accepting-an-answer-work)瞭解更多細節。也請考慮回去並接受過去的答案,這樣做會增加你的聲望並允許更多功能,請參閱[聲譽常見問題](http://stackoverflow.com/faq#reputation) – zaph

回答

1

蘋果使用EXIF標籤指定方向,並始終使用相同的尺寸方向(橫向),而不管拍攝照片時手機的方式如何。大多數平臺不考慮EXIF方向,並且存在互操作性問題。

對於互操作性,可能需要在上傳之前旋轉圖像並更改EXIF標記以匹配。

有關更多信息,請參閱EXIF Orientation Handling Is a Ghetto

+0

非常感謝! –

相關問題