减小相机图像选择器的尺寸

时间:2011-07-02 09:42:15

标签: iphone objective-c cocoa-touch ios4 iphone-sdk-3.0

我的问题是关于图像选择器(UIImagePickerControllerSourceTypeCamera)。当我在我的iPhone应用程序中按拍照时,默认大小为320x480。如何将其更改为任何其他维度,例如320x200或横向和纵向中的任何其他?

m_pImagePickerController = [[UIImagePickerController alloc] init];
m_pImagePickerController.delegate = self;
[m_pImagePickerController setSourceType:UIImagePickerControllerSourceTypeCamera];
[self.navigationController presentModalViewController:m_pImagePickerController animated:YES];

1 个答案:

答案 0 :(得分:0)

http://www.codza.com/custom-uiimagepickercontroller-camera-view

我正在使用以下代码在从选择器中检索后缩小图像。

代码:

+ (UIImage*)imageWithImage:(UIImage*)image 
          scaledToSize:(CGSize)newSize;
{
        UIGraphicsBeginImageContext( newSize );

        [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];

        UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext();

        UIGraphicsEndImageContext();

        return newImage;

}