Sunday, February 13, 2011

iPhone dev Stupidity 143: Size of Image Cut from CGContext

UIGraphicsBeginImageContext(scale_rect.size);
[self drawInRect: scale_rect];

UIImage * thumbnail = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

CGContext will always round to ceiling - trying to hold all drawings.

That means: scale_rect.size.width == 320.00000031 will be rounded to 321. If your app care that 1 point, it’ll cause error.

No comments: