• 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
NSImage rescaling
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSImage rescaling


  • Subject: NSImage rescaling
  • From: "David Piasecki" <email@hidden>
  • Date: Mon, 7 Feb 2005 14:57:52 -0800

<x-tad-smaller>I've been reading around online to try and get to the bottom of what seems to be a common problem. I'm scaling an NSImage object using the following code:

</x-tad-smaller>
NSImage *scaledImage = [image copy];
[scaledImage setScalesWhenResized:YES];
NSSize imageSize = [scaledImage size];
[scaledImage setSize:NSMakeSize(imageSize.width*zoom, imageSize.height*zoom)];
[imageView setImage:scaledImage];
[scaledImage release];

This works well; however, it is incredibly slow when the image gets very large. So rather than copy the image every time I want to enlarge or shrink the image in my NSImageView, I want the image to automatically rescale itself. So I decided to manually change the size of my NSImageView object and set the scale property to NSScaleProportionally. This doesn't appear to have any effect. Although the NSImageView size changes, the NSImage displayed remains the same size unless I copy the image and call [imageView setImage:scaledImage] again as in the code above. Another behavior I've observed in different attempts to solve this problem is to have the NSImage be displayed at a very poor resolution after zooming out and then trying to zoom back in again since NSImage's setSize method seems to cause the loss of information.

I'm sure this is really simple and that I'm going about it the wrong way, so I'd really appreciate it if someone could help by explaining how to have one image and simply scale it up or down based on the size of the NSImageView object which contains it.

Thanks,
David
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSImage rescaling
      • From: John Pannell <email@hidden>
  • Prev by Date: Re: Using NSDictionary to write to /Library/Prefererences
  • Next by Date: how to end editing on NSTableView?
  • Previous by thread: Re: Using NSDictionary to write to /Library/Prefererences
  • Next by thread: Re: NSImage rescaling
  • Index(es):
    • Date
    • Thread