【问题标题】:How to display the photo without lossing quality如何在不损失质量的情况下显示照片
【发布时间】:2012-09-06 05:59:49
【问题描述】:

您好,我是 iOS 新手。

我希望在我的应用中实现照片编辑功能。该照片将从 iPhone 照片库 中检索。我试图将照片放在 UIImageView 中。但我没有得到更好的结果。 UIImageview 不会将照片显示为在相册中。有很多分辨率和质量缺失。

如果我想在相册中显示具有原始分辨率和质量的照片。我需要遵循哪些步骤。如果有人知道,请指导我正确的方式。

    editingPhotoContainerIMV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, self.view.frame.size.height)];
    [editingPhotoContainerIMV setContentMode:UIViewContentModeScaleAspectFit];

【问题讨论】:

  • 如果您只是选择图像并将其添加到UIImageView,那么图像质量不会下降。在将图像添加到 UIImageView 之前,您确定没有应用任何图像处理,例如调整大小或任何其他东西?
  • 是的。我没有应用任何图像处理。

标签: iphone ios uiimageview camera photolibrary


【解决方案1】:

如果问题是您使用的是 Retina 设备,那么当您加载 UIImage 时,您应该使用:

UIImage *photoImage = [UIImage imageWithCGImage:(CGImageRef)imageRef scale:2 orientation: UIImageOrientationUp];

编辑:假设问题出在 Retina 设备上,那么您需要获取 CGImageRef。如果你已经有了 UIImage,那么你可以将上面的 'imageRef' 替换为 'myUIimage.CGImage'。如果不是,如果他的图像在文件中,那么您可以使用 UIImage 的 initWithContentsOfFile - 查看 UIImage 类参考。关键是从 UIImage 中取出 CGImage,然后得到一个比例因子为 2 的新图像。iOS 允许您这样做的唯一方法是使用我在顶部显示的方法。

【讨论】:

  • 感谢您的回复大卫,在 (CGImageRef)imageRef 我必须添加的内容。请给我建议
【解决方案2】:

试试 ALAssetRepresentation fullResolutionImage

【讨论】:

    猜你喜欢
    • 2019-10-26
    • 2015-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-19
    • 2021-10-13
    相关资源
    最近更新 更多