elliottbolzan
elliottbolzan

Reputation: 1077

UIImageView: Content Mode Aspect Fit Distorts Image

I'm trying to manually create a grid of images on the iPhone.

I've placed all my UIImageViews correctly, and they're all linked up correctly to the code. However, I have one small issue: my images are too big, and therefore, they need downscaling.

This shouldn't be much of a problem, as UIImageViews accept the "Aspect Fit" setting as a content mode; however, when an image is assigned to the image view, it is clearly slightly blurry and distorted.

Here is the original image, in full-size:

and here is the thumbnail image:

Now, it is quite obvious the second image is messed up in some ways, especially on the player's jersey number.

I imagine this has something to do with the resizing algorithm utilized by the SDK; should I be resizing images on my own before handing them over to UIImageView, or does the problem lie somewhere else ?

For the sake of completeness, here's the code I'm using, even though I'm certain this isn't where the problem originates from:

NSString *file = [[NSBundle mainBundle] pathForResource:@"image" ofType:@"jpg"];
UIImage *image = [UIImage imageWithContentsOfFile:file];
image1.image = image;

EDIT: I'm not sure if this is important, but the original image is in the JPG format.

Upvotes: 2

Views: 3592

Answers (1)

andreamazz
andreamazz

Reputation: 4286

Yes, resizing the image prior to the assignment to its ImageView will reduce the jaggies that you see. To resize a UIImage you can check this answer

Upvotes: 4

Related Questions