Wrong sized UIImagePickerController image

I use UIImagePickerController UIViewas a subview of my own subtext UIViewController's UIView. Nothing special about this, the problem arises when I take a picture. Something like that:

1 The image that I see from the view UIImagePickerControllerlooks something like this:

enter image description here

2 This is what I see when I take a picture ( [self.imagePicker takePicture]; ) and put it on UIImageView:

enter image description here

From what I see, the image that comes out is slightly higher on the y axis. Is there a way to solve this? I don't care if I have to use some kind of crop with the image that appears in:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info;

I can understand this behavior because I use UIViewContentModeScaleAspectFillin UIImageView contentMode, but I would like to be able to tell Y where I want to start looking.

+4
1

28 , , :

CGImageRef imageRef = CGImageCreateWithImageInRect([imageTaken CGImage], CGRectMake(0.0f, 0.0f, 960.0f, 960.0f));

[selectedImageView setImage:[UIImage imageWithCGImage:imageRef]];
CGImageRelease(imageRef);

960.0f, , , Y . :

+ (UIImage*)rotate:(UIImage*)image andOrientation:(UIImageOrientation)orientation;
{
    UIGraphicsBeginImageContext(image.size);

    CGContextRef context=(UIGraphicsGetCurrentContext());

    if (orientation == UIImageOrientationRight) {
        CGContextRotateCTM (context, 90/180*M_PI) ;
    } else if (orientation == UIImageOrientationLeft) {
        CGContextRotateCTM (context, -90/180*M_PI);
    } else if (orientation == UIImageOrientationDown) {
        // NOTHING
    } else if (orientation == UIImageOrientationUp) {
        CGContextRotateCTM (context, 90/180*M_PI);
    }

    [image drawAtPoint:CGPointMake(0, 0)];
    UIImage *img=UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return img;
}

, .

+4

All Articles