Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

Aspect fit scaling results in image one pixel too large #16

Open
nathan-alden-sr opened this issue Nov 9, 2013 · 0 comments
Open

Aspect fit scaling results in image one pixel too large #16

nathan-alden-sr opened this issue Nov 9, 2013 · 0 comments

Comments

@nathan-alden-sr
Copy link

This bug occurs with the resizedImageWithContentMode method.

I am passing an image whose dimensions are reported to be 4877x3515. When I supply a bounds parameter of 1000x1000, the resultant image's size is 1001x721.

I believe the bug is on this line:

CGSize newSize = CGSizeMake(self.size.width * ratio, self.size.height * ratio);

It looks like the resultant width is 1000.0001. The resultant width and height should be MINed with the bounds parameter:

CGSize newSize = CGSizeMake(MIN(bounds.width, self.size.width * ratio), MIN(bounds.height, self.size.height * ratio));

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant