【发布时间】:2012-06-07 09:51:27
【问题描述】:
我正在与 AVFoundation 合影,如下所示: http://red-glasses.com/index.php/tutorials/ios4-take-photos-with-live-video-preview-using-avfoundation/
一个sn-p:
[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
但这里只有少数可能的设置,不能设置为自定义大小。
如果可能,我希望拍摄的照片具有 1:1 的纵横比,例如 400x400 像素(方形图片)。 似乎 instagram 正在这样做(或者他们正在裁剪图像?)。
如何将拍摄的图片指定为正方形?我知道如何在手机上更改尺寸,但是如果拍摄的照片不是正方形,效果不好。
有什么想法吗?
【问题讨论】:
标签: iphone camera uiimage avfoundation instagram