I have the portrait version working fine as the scale is 0.75. But I cannot get the landscape to work correctly. I am using UIImagePickerController.
// Landscape
// Full landscape image is width: 3264 and height 2448
CGRect cropped = CGRectMake(306.0, 0.0, 1836.0, 2448.0);
CGImageRef imageRef = CGImageCreateWithImageInRect ([photo CGImage], cropped);
// UIImage * croppedPhoto = [UIImage imageWithCGImage: imageRef];
UIImage * croppedPhoto = [UIImage imageWithCGImage:imageRef scale:photo.scale orientation:UIImageOrientationUp];
CGImageRelease (imageRef);
// Scale the photo down
CGRect rect = CGRectMake(0.0, 0.0, 450.0, 600.0);
UIGraphicsBeginImageContext( rect.size );
[croppedPhoto drawInRect:rect];
picture = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
I have the following issues:
I want the edges cut off to make the landscape into a portrait (the center part of the landscape needs to be converted to portrait).
Depending on which way I hold the device, the image is either upside down or correct.
What am I doing wrong?