imageNamed vs imageWithContentsOfFile
I've changed one to another, and discovered that imageWithContentsOfFile is much slower than imageNamed, probably about 2-2.5 times. Is it normal? Any ideas how to avoid caching and still retain speed?
I haven't noticed any difference in loading times myself, although I've been careful not to be loading anymore images than immediately needed.
Instead of using the UIImage routines, you can do something like this instead:
[adding] Oh yeah, and don't forget to release them yourself once you're done loading, with:
Instead of using the UIImage routines, you can do something like this instead:
Code:
CGImageRef image;
CGDataProviderRef source;
source = CGDataProviderCreateWithURL((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:myImageName ofType:@"png"]]);
image = CGImageCreateWithPNGDataProvider(source, nil, NO, kCGRenderingIntentDefault);[adding] Oh yeah, and don't forget to release them yourself once you're done loading, with:
Code:
CGImageRelease(image);
CGDataProviderRelease(source);
