将高分辨率图像保存到相册
我正在开发一个简单的图像处理应用程序,我在我的测试设备(iPhone 3G)上遇到了一个问题,通常任何超过 1024x1024 像素的图像都会导致应用程序在保存时崩溃。
我的应用程序的流程如下:
用户通过 UIImagePicker 选择图像
创建所选图像的工作副本并将其大小调整为视图边界(例如 320x480)以提高性能。
用户在工作副本上进行图像操作并按保存
对原始全分辨率图像进行相同的操作,然后保存到相册。
如果图像是 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:
User selects an image via UIImagePicker
A working copy of the selected image is created and resized to the view bounds (e.g. 320x480) for performance.
User does their image manipulations on the working copy and presses save
The same manipulations are done on the original full-res image, then saved to the photo album.
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
即使没有内存警告,我也认为这是一个内存问题。我们需要有关您的事故的更多信息才能确定。你如何保存它?您使用 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.
我想分享一下我如何解决这个问题...
并不理想,但至少这可以防止崩溃,并允许拥有较新硬件(例如 3G 或 4)的个人以更高分辨率保存。
Thought I'd share how I moved forward with this issue...
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.