关于@ 2X的问题 [英] Problem about @2X

查看:57
本文介绍了关于@ 2X的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1.我使用下面的代码截取截图。有必要改变它为高分辨率

1.I use below code for take screenshot.is it necessary to change it for high resolution

UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.window.layer renderInContext:UIGraphicsGetCurrentContext()]; 
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

2.如果我只使用一个640 * 960分辨率的图像,质量? (意味着不要使用@ 2x格式的图像)

2.what does happen if i just use one image with 640*960 resolution for both low and high quality ? (means that don't use image with @2x)

推荐答案

这只会使用正常(320x480)分辨率的屏幕截图。所以在回答1,是的。

That will only take normal (320x480) resolution screenshots. So in answer to 1, yes. Older generation devices can do double resolution too, the screen just can't display it.

要在设备的res上截取屏幕截图,您可以这样做:

To take a screenshot at the res of the device you can do this:

CGSize size = self.view.bounds.size;
CGFloat scale = 1.0f;
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
    scale = [[UIScreen mainScreen] scale];
    size = CGSizeApplyAffineTransform(size, CGAffineTransformMakeScale(scale, scale));
}

UIGraphicsBeginImageContext(size);

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextScaleCTM(context, scale, scale);

[self.view.layer renderInContext:context]; 
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

在旧设备上进行双重打印会起作用,如果显示在屏幕上,则会缩小。但不推荐,只是浪费。

Taking double res on older devices does work, and will be scaled back down if displayed on screen. But is not recommended, and simply a waste.

这篇关于关于@ 2X的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆