• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Scaling a NSImage not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scaling a NSImage not working


  • Subject: Re: Scaling a NSImage not working
  • From: Quincey Morris <email@hidden>
  • Date: Wed, 01 Jun 2011 22:02:15 -0700

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 (email@hidden)

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:

This email sent to email@hidden

References: 
 >Scaling a NSImage not working (From: Development <email@hidden>)
 >Re: Scaling a NSImage not working (From: Development <email@hidden>)

  • Prev by Date: Re: Scaling a NSImage not working
  • Next by Date: Notify With Parameters
  • Previous by thread: Re: Scaling a NSImage not working
  • Next by thread: Re: Scaling a NSImage not working
  • Index(es):
    • Date
    • Thread