Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cropped squares sometimes have either width or height that is a pixel too small #30

Open
joshbernfeld opened this issue Aug 7, 2013 · 0 comments

Comments

@joshbernfeld
Copy link

This problem is caused because the scale is not always a whole number in the croppedImage function.

When the rect is scaled up, non full pixels are often created. When the CGImageCreateWithImageInRect cropping function crops the image, it rounds those non full pixels up!

This can be solved by changing this

static CGRect GKScaleRect(CGRect rect, CGFloat scale)
{
    return CGRectMake(rect.origin.x * scale, rect.origin.y * scale, rect.size.width * scale, rect.size.height * scale);
}

to this

static CGRect GKScaleRect(CGRect rect, CGFloat scale)
{
    return CGRectMake(floor(rect.origin.x * scale), floor(rect.origin.y * scale), floor(rect.size.width * scale), floor(rect.size.height * scale));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant