gpt4 book ai didi

ios - 如何将视网膜捕获的图像绘制回视网膜并保持高质量?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:20:56 26 4
gpt4 key购买 nike

我有一个应用程序可以在 Retina-iPad (iPad3) 上进行屏幕截图。或者也许我只是使用 HOME+POWER 进行屏幕截图并以这种方式获取图像,这并不重要。最后,我捕获了一张 2048x1536 的图像——即 1024x768 @2x。

现在我想在屏幕上显示这张图片——这张 2048x1536 的图片,我想保留它可爱的视网膜感。

当我做这样的事情时(在网络浏览器中输入代码):

UIImage *myImage = [UIImage imageWithContentsOfFile: pathToMyHiresImage];
UIImageView *myImageView = [[UIImageView alloc] initWithImage: myImage];
myImageView.frame = screenBounds; // make it fit
// etc...

我最终得到了图像的低分辨率(锯齿状对角线和文本)版本。

所以我的问题是:我需要做什么才能在屏幕上显示该图像并使其显示 @2x-DPI,使其具有漂亮的视网膜外观?

谢谢!

最佳答案

这应该可以解决问题:

UIImage *myImage = [UIImage imageWithContentsOfFile: pathToMyHiresImage];
// *****Added Code*****
myImage = [UIImage imageWithCGImage:myImage.CGImage scale:2 orientation:myImage.imageOrientation];
// ********************
UIImageView *myImageView = [[UIImageView alloc] initWithImage: myImage];
myImageView.frame = screenBounds; // make it fit
// etc ...

祝你好运!

编辑(奥利)这是最终代码,考虑了 DavidH 的建议:

UIImage *myImage = [[UIImage alloc] initWithContentsOfFile: path];

if ([[UIScreen mainScreen] respondsToSelector: @selector(scale)])
{
float screenScale = [[UIScreen mainScreen] scale];
if (screenScale > 1.)
{
id oldImage = myImage;
myImage = [[UIImage imageWithCGImage: myImage scale: screenScale orientation: myImage.imageOrientation] retain];
[oldImage release];
}
}

关于ios - 如何将视网膜捕获的图像绘制回视网膜并保持高质量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11552658/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com