将高分辨率图像保存到相册

发布于 2024-09-27 11:37:18 字数 584 浏览 2 评论 0原文

我正在开发一个简单的图像处理应用程序,我在我的测试设备(iPhone 3G)上遇到了一个问题,通常任何超过 1024x1024 像素的图像都会导致应用程序在保存时崩溃。

我的应用程序的流程如下:

  1. 用户通过 UIImagePicker 选择图像

  2. 创建所选图像的工作副本并将其大小调整为视图边界(例如 320x480)以提高性能。

  3. 用户在工作副本上进行图像操作并按保存

  4. 对原始全分辨率图像进行相同的操作,然后保存到相册。

  5. 如果图像是 1024x1024 的区域,一切都很好,如果太大,应用程序崩溃没有任何内存警告。

在 stackoverflow 搜索后,似乎 Apple 建议不要超过 1024x1024,但是我发现 PhotoShop Express 应用程序在同一位置iPhone 3G 能够以原始高分辨率(例如 1534x2034)保存图像。

有人可以给我一些关于如何像 PhotoShop Express 那样将高分辨率图像保存到相册的想法吗?

谢谢。

I'm developing a simple image processing app and I've encountered an issue on my test unit (iPhone 3G) that generally any image over 1024x1024 pixels will cause the app to crash when saving.

The process my app follows:

  1. User selects an image via UIImagePicker

  2. A working copy of the selected image is created and resized to the view bounds (e.g. 320x480) for performance.

  3. User does their image manipulations on the working copy and presses save

  4. The same manipulations are done on the original full-res image, then saved to the photo album.

  5. If the image is is the region of 1024x1024 all is fine, if too large the app crashes without any memory warning.

After searching through stackoverflow it seems that there this a recommendation from Apple to not exceed 1024x1024, however I've found that the PhotoShop Express app on the same iPhone 3G is able to save images at their original high resolution (e.g. 1534x2034).

Could someone give me some ideas as to how to save high-res images to the photo album like PhotoShop Express is able to?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝礼 2024-10-04 11:37:18

即使没有内存警告,我也认为这是一个内存问题。我们需要有关您的事故的更多信息才能确定。你如何保存它?您使用 ALAssetsLibrary 或 UIImageWriteToSavedPhotosAlbum 吗?请注意,后者具有与 CGImageRef 或 NSData 一起使用的方法。值得尝试所有适用的方法进行比较。

Even though there is no memory warning, I'm assuming this is a memory issue. We'd need more information about your crash to know for sure. How are you saving it? Are you using ALAssetsLibrary or UIImageWriteToSavedPhotosAlbum? Note that the latter has methods that work with CGImageRef or NSData. Its worth trying all applicable methods to compare.

日记撕了你也走了 2024-10-04 11:37:18

我想分享一下我如何解决这个问题...

  1. 从照片库加载图像。 [imginfo objectForKey:@"UIImagePickerControllerOriginalImage"];
  2. 将“工作副本”的大小调整为适合视图边界的大小。
  3. 保存时,我有一个方法可以确定它在哪种型号的 iOS 设备上运行,并返回一维的最大分辨率。对于 iPhone 3G,我使用 1600px。
  4. 再次加载原始图像 (objectForKey:@"UIImagePickerControllerOriginalImage"];),然后调整大小以适合 1600px 的范围(在本例中),同时保持纵横比。

并不理想,但至少这可以防止崩溃,并允许拥有较新硬件(例如 3G 或 4)的个人以更高分辨率保存。

Thought I'd share how I moved forward with this issue...

  1. Load the image from photo library. [imginfo objectForKey:@"UIImagePickerControllerOriginalImage"];
  2. Resize a "working copy" to a size that fits in the view bounds.
  3. At the time of saving, I have a method which determines which model iOS device it's running on, and returns that max resolution for one dimension. For iPhone 3G I used 1600px.
  4. The original image is loaded again (objectForKey:@"UIImagePickerControllerOriginalImage"];) then resized to fit within the bounds of 1600px (in this case) whilst maintaining the aspect ratio.

Not ideal, but at least this prevents the crash, and allows individuals with newer hardware (e.g. 3Gs or 4) to save at higher resolutions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文