Giter VIP home page Giter VIP logo

Comments (8)

skizzo avatar skizzo commented on June 10, 2024 1

Maybe it's because I use a pretty huge image in a small UIImageView, don't know to be honest. I'll let you know if there are performance drops, right now I have to get to a point of being able to determine that :)

from aggeometrykit.

hfossli avatar hfossli commented on June 10, 2024

Hello @skizzo ! Thanks for the kind words!

Are you talking about views in general using the layer.quadrilateral API or are you talking about images you are rendering using this API

@interface UIImage (AGKQuad)

- (UIImage *)imageByCroppingToQuad:(AGKQuad)quad destinationSize:(CGSize)destinationSize;
- (UIImage *)imageByCroppingToRect:(CGRect)rect;
- (UIImage *)imageWithPerspectiveCorrectionFromQuad:(AGKQuad)quad;

@end

?

from aggeometrykit.

skizzo avatar skizzo commented on June 10, 2024

sorry, i actually mean both but could live with a preview as it is (setting the quad of a UIView) but a better looking rendering!

from aggeometrykit.

hfossli avatar hfossli commented on June 10, 2024

Allright, I get you. With regards to the preview there's some pretty quick and easy fixes I would recommend. https://markpospesel.wordpress.com/2012/03/30/efficient-edge-antialiasing/
Especially the transparent line trick!

When it comes to rendering to UIImage this is already an issue, #23. We can continue discussion at that issue.

from aggeometrykit.

skizzo avatar skizzo commented on June 10, 2024

Unfortunately, neither of the approaches mentioned in the link change anything about how the edges are displayed, but thanks.

from aggeometrykit.

hfossli avatar hfossli commented on June 10, 2024
+ (UIImage *)renderImageForAntialiasing:(UIImage *)image withInsets:(UIEdgeInsets)insets
{
    CGSize imageSizeWithBorder = CGSizeMake([image size].width + insets.left + insets.right, [image size].height + insets.top + insets.bottom);

    // Create a new context of the desired size to render the image
    UIGraphicsBeginImageContextWithOptions(imageSizeWithBorder, NO, 0);

    // The image starts off filled with clear pixels, so we don't need to explicitly fill them here 
    [image drawInRect:(CGRect){{insets.left, insets.top}, [image size]}];

    // Fetch the image   
    UIImage *renderedImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return renderedImage;
}

This didn't work?

Assumed old code

self.imageView.image = [UIImage imageWithName:@"foo.jpg"];

New code

UIImage *original = [UIImage imageWithName:@"foo.jpg"];
UIImage *aliased = [self renderImageForAntialiasing:original withInsets:UIEdgeInsetsMake(1, 1, 1, 1)];
self.imageView.image = aliased;

from aggeometrykit.

skizzo avatar skizzo commented on June 10, 2024

Nope, tried exactly this code. Turns out that this line solved the anti-aliasing problem:

[self.imageView.layer setMinificationFilter:kCAFilterTrilinear];

No hard edges any more :)

from aggeometrykit.

hfossli avatar hfossli commented on June 10, 2024

Huh, I find that really really strange. I've used that technique many times.

Any performance drops using setMinificationFilter:?

from aggeometrykit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.