On Jun 1, 2011, at 21:29, Development wrote:

> Was I completely mistaken in thinking that the way I'm doing this was suppose 
> to preserve the aspect ratio?

Yes, completely mistaken.

It may help to think of the source and destination rectangle as an origin and a 
size separately.

The source rect *origin* is the point in the source image which will appear at 
the destination rect *origin*.

The source rect *size* is the portion of the source image which will be scaled 
to fill the destination rect *size*.

Therefore, if you wish to preserve the aspect ratio, you must calculate a dest 
rect size that has the same aspect ratio as the source rect size. This is one 
of those slightly annoying calculations, because you have to decide whether you 
want to use the width or the height of the source rect to determine the 
aspect-ratio-preserving scale factor. That usually means you calculate 2 
different scales, and choose whichever is smaller.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to