Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading an ico image switches red channel with the blue one

This is what I do: I have a favicon.ico in my resources (for example http://google.com/favicon.ico)

Then I have a UIImageView which loads that image.

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

The image showed in the simulator or the in iPhone is the same but with the red color switched with the blue one. Could it be a loading bug from apple?

I also have the same result downloading directly from Internet:

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

Thanks David.

like image 344
LightMan Avatar asked Jan 28 '26 20:01

LightMan


1 Answers

I have found this work around:

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

Basically file is loaded and then converted it to an PNG UIImage, and it works. Anyway I also used the Libnsbmp library and then some Quartz code to integrate it, it worked fine but I think that the work around runs faster.

like image 190
LightMan Avatar answered Jan 30 '26 11:01

LightMan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!