私はここのようにAVFoundationで写真を撮っています:http: //red-glasses.com/index.php/tutorials/ios4-take-photos-with-live-video-preview-using-avfoundation/
1つのスニペット:
[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error)
{
CFDictionaryRef exifAttachments = CMGetAttachment( imageSampleBuffer, kCGImagePropertyExifDictionary, NULL);
if (exifAttachments)
{
// Do something with the attachments.
NSLog(@"attachements: %@", exifAttachments);
}
else
NSLog(@"no attachments");
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
UIImage *image = [[UIImage alloc] initWithData:imageData];
私が見つけた限りの画像サイズはここに設定されています:
AVCaptureSession *session = [[AVCaptureSession alloc] init];
session.sessionPreset =AVCaptureSessionPresetMedium; //medium on my iphone4 is 640*480
ただし、可能な設定はごくわずかであり、カスタムサイズに設定することはできません。
可能であれば、400x400ピクセル(正方形の写真)のように、アスペクト比を1:1にして写真を撮りたいと思います。Instagramがそれをやっているようです(または彼らは画像をトリミングしていますか?)。
撮影した写真のサイズを正方形に指定するにはどうすればよいですか?携帯電話でサイズを変更する方法は知っていますが、撮影した写真が正方形でない場合、結果は良くありません。
何か案が?