tImageFromCurrentImageContext视网膜

tImageFromCurrentImageContext视网膜

本文介绍了UIGraphicsGetImageFromCurrentImageContext视网膜分辨率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UIImageView *cellimage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0 , 107, 70)];

我相信以上声明将在视网膜分辨率设备和标准设备中制作合适的尺寸。是一个标准的107 x 70像素和视网膜上的214 x 140的帧。

The above statement i am sure will make appropriate sizes in both retina resolution devices and standard ones..that is a frame of 107 x 70 pixels on standard and 214 x 140 on retina.

我想知道的是下面的 UIGraphicsGetImageFromCurrentImageContext 也是一样的..图像标准为67 x 67,视网膜版本为124 x 124?

What i want to know is if the below UIGraphicsGetImageFromCurrentImageContext does the same too.. image will be 67 x 67 for standard and 124 x 124 for retina versions?

    CGSize imagesize = CGSizeMake(67, 67);
        UIGraphicsBeginImageContext(imagesize);
        NSLog(@" Converting ");
        [image drawInRect:CGRectMake(0,0,imagesize.width,imagesize.height)];
        newImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();

如果没有人能告诉我如何区分模型。
谢谢

if not can anyone tell me how to differentiate between models.?Thanks

推荐答案

您需要使用 UIGraphicsBeginImageContextWithOptions 而不是 UIGraphicsBeginImageContext ,以便您可以指定图像的比例因子。这将使用设备主屏幕的比例因子:

You need to use UIGraphicsBeginImageContextWithOptions instead of UIGraphicsBeginImageContext, so that you can specify the scale factor of the image. This will use the scale factor of the device's main screen:

UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);

这将使用包含 cellImage ,如果 cellImage 在屏幕上:

This will use the scale factor of the screen containing cellImage, if cellImage is on a screen:

UIGraphicsBeginImageContextWithOptions(imageSize, NO, cellImage.window.screen.scale);

这将对比例因子进行硬编码:

This will hardcode the scale factor:

UIGraphicsBeginImageContextWithOptions(imageSize, NO, 2);

这篇关于UIGraphicsGetImageFromCurrentImageContext视网膜分辨率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 20:49