gpt4 book ai didi

iphone - 加载 ico 图像会切换红色 channel 和蓝色 channel

转载 作者:行者123 更新时间:2023-12-03 20:00:35 26 4
gpt4 key购买 nike

这就是我所做的:我的资源中有一个 favicon.ico(例如 http://google.com/favicon.ico )

然后我有一个加载该图像的 UIImageView。

self.imgTestIcon.image = [UIImage imageNamed:@"favicon.ico"];

模拟器或iPhone中显示的图像是相同的,但红色与蓝色交换了。会不会是苹果的加载错误?

我也直接从互联网下载相同的结果:

self.imgTestIcon.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://google.com/favicon.ico"]]];

谢谢大卫。

最佳答案

我找到了解决办法:

icon = [UIImage imageWithContentsOfFile:path];
icon = [UIImage imageWithData:UIImagePNGRepresentation(icon)];

基本上文件被加载,然后将其转换为 PNG UIImage,并且它可以工作。无论如何,我还使用了 Libnsbmp 库,然后使用一些 Quartz 代码来集成它,它工作得很好,但我认为解决方法运行得更快。

关于iphone - 加载 ico 图像会切换红色 channel 和蓝色 channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3855913/

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