Damaged edges in images when they rotate

I have a square white image on a black background. When I rotate the image, the edges become very jagged. It really doesn't look good. Are there any settings you can use to make the phone smooth the image when it manipulates it? Or is it the only real option to ask the artist to use some kind of artist’s technique, such as smoothing (I don’t know if this is right) or something else? I saw minificationFilter in docs for scaling. Maybe there is something similar that might be appropriate for my problem, which I have not yet found in the docs. Any clues guys?

Thanks a lot, code

+5
source share
2 answers

If you do not have iOS 4 / openGL, you have a hack that works almost as well. Leave a 1px transparent border around all of your images - the transparent border is jagged, but you cannot tell because it is transparent. The inside of the image should look smooth :)

Although it is obvious that this only works if you have access to the source images. Otherwise, you need to load the image, display it in a graphic context using the border and use the new image :( If you have the originals / access to the designer, just tell him / her to add a 1px transparent frame and your current code should be " just work "

+5
source

To add a 1px transparent border to your image, use

    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();
+12

All Articles