I have an square white image against a black back ground. When i rotate the image the edges become very jagged. Its really doesn't look good. Are there any settings that you can use to get the phone to smoothen out the image when it manipulates it? Or is the only real option to ask the artist to use some artist technique like anti aliasing(dont know if thats the correct term) or something? I've seen minificationFilter in the docs for scaling.. maybe there is something like this that might be appropriate for my problem that I haven'开发者_C百科t found in the docs yet. Any hints guys?
Many Thanks, -Code
To add 1px transparent border to your image use this
CGRect imageRrect = CGRectMake(0, 0, image.size.width, image.size.height);
UIGraphicsBeginImageContext( imageRrect.size );
[image drawInRect:CGRectMake(1,1,image.size.width-2,image.size.height-2)];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
If you don't have iOS 4 / openGL to hand, there's a hack that works almost as well. Leave a 1px transparent border around all youur images - the transparent border is jagged but you can't tell because it's transparent. The inside of the image should look smooth :)
Though obviously this only works easily if you have access to the original images. Otherwise you have to load the image, render it into a graphics context with the border and use the new image :( If you have the originals / access to the designer, just tell him/her to add 1px transparent border and your current code should 'just work'
精彩评论