拍照iPhone拉伸

时间:2014-02-21 05:44:35

标签: ios iphone objective-c ipad ios7

我为iPhone 5纵向和横向模式拍摄了照片。照片尺寸缩小320 * 242 两种模式,但纵向模式照片拉伸和景观工作完美

图像视图内容模式设置aspectfill。 instagram应用程序拍摄照片横向和纵向模式。不拉伸任何尺寸保持320 * 427的照片

我的didfinishwithmedia信息代码如下:

 else if ([mediaType isEqualToString:(__bridge NSString *)kUTTypeImage])
{
    _imgcount = 0;
[self dismissViewControllerAnimated:YES completion:^{
    UIImage *image = [info objectForKey: UIImagePickerControllerOriginalImage];
    CGFloat imgHeight = image.size.height;
    CGFloat imgWidth = image.size.width;
    CGFloat resizeWidth = 320;
    CGFloat resizeHeight = 240;
    if (imgWidth > imgHeight) {
        resizeHeight = imgHeight * 320/imgWidth;
    }
    else if (imgWidth < imgHeight || imgHeight == imgWidth){
        resizeWidth = imgWidth * 240/imgHeight;
    }
     UIImage *compressedImage = [self scaleImage:image toSize:CGSizeMake(resizeWidth, resizeHeight)];
    if (checkgallery) {
        _imgcount += 1;
        imgBannerimage.image = compressedImage;
    }
    else{
        strMediatype = [NSString stringWithFormat:@"image"];
        imgtblVideo.image =compressedImage;
    }
    [tblDealership reloadData]; // Update table UI
}];
 }




 -(UIImage *)scaleImage:(UIImage *)image toSize:(CGSize)newSize
  {
//    UIGraphicsBeginImageContext(newSize);
 UIGraphicsBeginImageContextWithOptions(newSize,NO,0.0);
 [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
 UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
 UIGraphicsEndImageContext();
  return newImage;
  }

建议您的想法..

0 个答案:

没有答案