【问题标题】:Saving really big uiimage files保存非常大的 uiimage 文件
【发布时间】:2013-09-12 06:37:58
【问题描述】:

我制作了一个应用程序,它可以创建由文本组成的非常大的图像(最大的图像大约是 iPhone 屏幕大小的十倍)。我尝试使用UIImageWriteToSavedPhotosAlbum,但它以低得多的分辨率保存。有没有办法以全质量保存图像?

【问题讨论】:

    标签: ios objective-c uiimage


    【解决方案1】:

    看看NSFileManager。在您的应用程序沙箱中创建一个子目录,您将在其中保存文件(图像)。如果您不希望将图像保存在 iOS 相册中并将其私有用于您的应用程序,这当然是相关的。

    【讨论】:

      【解决方案2】:
      - (UIImage *)renderLayerOf:(UIView *)yourView {
           //in this case 'yourView' is the label containing the large text
          UIGraphicsBeginImageContext(yourView.frame.size);
          CGContextRef context = UIGraphicsGetCurrentContext();
          [[yourView layer] renderInContext:context];
          UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
          return image;
      }
      

      此方法会将任何 UIView 转换为 Image。获得图像后,您可以保存使用 NSFileManager。希望对您有所帮助。

      【讨论】:

        猜你喜欢
        • 2020-08-13
        • 1970-01-01
        • 1970-01-01
        • 2020-06-05
        • 2011-04-21
        • 2013-05-14
        • 1970-01-01
        • 2014-06-06
        • 1970-01-01
        相关资源
        最近更新 更多