UIGraphicsGetImageFromCurrentImageContext给出质量差/低分辨率图像,我如何得到更好? [英] UIGraphicsGetImageFromCurrentImageContext gives poor quality / low resolution image, how do I get better?
问题描述
好的,所以我正在拍摄的照片,我用我的相机在iPhone上拍摄的屏幕截图。我把相机照片放到UIImageView,并抓住它的屏幕截图使用这种代码(这是从 http://www.skylarcantu.com/blog/2009/10/16/saving-a-view-as-an-image/ ) ...
Ok so I am taking a screen shot of a photo I took with my camera on the iPhone. I put the camera photo into UIImageView and grab a screenshot of it using this sort of code (this is from http://www.skylarcantu.com/blog/2009/10/16/saving-a-view-as-an-image/)...
- (void)takeScreenshot {
UIWindow *theScreen = [[UIApplication sharedApplication].windows objectAtIndex:0];
UIGraphicsBeginImageContext(theScreen.frame.size);
[[theScreen layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[self doSomethingWith:screenshot];
}
我按照我想要的方式工作,但截图的图像质量比我用相机拍摄的图像差。有办法克服这个吗?我想这是因为这需要一个截图,捕获的iPhone屏幕的分辨率,而不是相机的分辨率 - 也许?
I have it working as I want but the image quality of the screenshot is much worse than the image I take with my camera. Is there a way to overcome this? I guess it is because this takes a screenshot which captures the resolution of the iPhone screen rather than the resolution of the camera - maybe?!
任何建议是伟大的: )
Any suggestions would be great :-)
推荐答案
你是完全正确的。屏幕分辨率(320 x 480)远远小于摄像头(3G上为1200 x 1600,3GS上为1536 x 2048),因此您的UIImageView必须为320x480,并且会自动降低图片大小。这似乎很复杂,虽然 - 你已经有照片作为一个UIImage在较高的分辨率 - 你试图覆盖的东西在上面或什么?
You're exactly right. The resolution of the screen (320 x 480) is much less than the camera (1200 x 1600 on 3G, 1536 x 2048 on the 3GS) so your UIImageView must be 320x480, and it automatically downsamples your image to fit. This seems convoluted, though -- you already have the photo as a UIImage at the higher resolution -- are you trying to overlay things onto it or something?
这篇关于UIGraphicsGetImageFromCurrentImageContext给出质量差/低分辨率图像,我如何得到更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!