iPhone - 以更高分辨率保存图像而不对其进行像素化
我正在使用图像选择器控制器从用户那里获取图像。 对图像进行一些操作后,我希望用户能够以 1600x1200 px、1024x1024 px 或 640x480 px 保存图像(类似于 iFlashReady 应用程序)。
最后一个选项是我在 UIImagePickerControllerDelegate 方法中获得的图像大小(当使用相机胶卷中的图像时)
有什么方法可以在不像素化图像的情况下以这些分辨率保存图像?
我尝试创建一个具有我想要的宽度和高度的位图上下文(CGBitmapContextCreate)并在那里绘制图像。 但图像在 1600x1200 时会出现像素化。
谢谢
I am using the image picker controller to get an image from the user. After some operations on the image, I want the user to be able to save the image at 1600x1200 px, 1024x1024 px or 640x480 px (something like iFlashReady app).
The last option is the size of image I get in the UIImagePickerControllerDelegate method (when using image from camera roll)
Is there any way we can save the image at these resolutions without pixelating the images?
I tried creating a bitmap context with the width and height I want (CGBitmapContextCreate) and drawing the image there. But the image gets pixelated at 1600x1200.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据很久以前计算机视觉课的模糊记忆,我认为你所做的就是在上转换后模糊图像。
From faint memories of computer vision class from long ago, I think what you do is to blur the image after the up-convert.
在绘制之前尝试调整 CGBitmapContext 的抗锯齿和/或插值质量:
CGContextSetShouldAntialias( context, 1 == 1 )
CGContextSetInterpolationQuality( context, kCGInterpolationHigh ) ;
如果我没记错的话,抗锯齿是默认情况下关闭 CGContext。
Before drawing try adjusting your CGBitmapContext's antialiasing and/or interpolation quality:
CGContextSetShouldAntialias( context, 1 == 1 )
CGContextSetInterpolationQuality( context, kCGInterpolationHigh ) ;
If I remember right, antialiasing is turned off on CGContext by default.
这一点很重要。 您的图像没有足够的数据。 要放大它,您需要重新采样图像并在像素之间进行插值(就像调整图像大小时在 Photoshop 中一样)。
您很可能想要使用第三方库,例如:
http: //code.google.com/p/simple-iphone-image-processing/
它执行此功能和许多其他图像处理功能。
This is non-trivial. Your image just doesn't have enough data. To enlarge it you'll need to resample the image and interpolate between pixels (like photoshop when you resize an image).
Most likely you'll want to use a 3rd party library such as:
http://code.google.com/p/simple-iphone-image-processing/
This performs this and many other image processing functions.