我是XCode的新手,我想从照片库中选择一张照片。
- (void) ChoosePhoto_from_Album
{
UIImagePickerController *imgage_picker = [[UIImagePickerController alloc] init];
imgage_picker.delegate = self;
imgage_picker.allowsEditing = YES;
imgage_picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:imgage_picker animated:YES completion:NULL];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage * image = [info objectForKey:UIImagePickerControllerOriginalImage];
NSLog(@"ImagePicker image size = (%.0f x %.0f)", image.size.width , image.size.height);
// process image...
}
我选择的照片是500万像素(2592x1936)。但是,它返回的大小是960x716。 我缺少什么?
谢谢!
答案 0 :(得分:0)
我找到了这个链接。您可以使用以下包含代码来使用Three20 Framework。
这是您的solution。
答案 1 :(得分:0)
UIImagePickerController
会为您提供完整的基于相机的图像。您需要从editingInfo
方法的imagePickerController:didFinishPickingImage:editingInfo
参数中获取它。
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
CGImageRef ref = image.CGImage;
int width = CGImageGetWidth(ref);
int height = CGImageGetHeight(ref);
NSLog(@"image size = %d x %d", width, height);
UIImage *orig = [editingInfo objectForKey:UIImagePickerControllerOriginalImage];
ref = orig.CGImage;
width = CGImageGetWidth(ref);
height = CGImageGetHeight(ref);
NSLog(@"orig image size = %d x %d", width, height);
CGRect origRect;
[[editingInfo objectForKey:UIImagePickerControllerCropRect] getValue:&origRect];
NSLog(@"Crop rect = %f %f %f %f", origRect.origin.x, origRect.origin.y, origRect.size.width, origRect.size.height);
}