• 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: Lame problem with NSImageView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Lame problem with NSImageView


  • Subject: Re: Lame problem with NSImageView
  • From: Michael Heinz <email@hidden>
  • Date: Wed, 3 Nov 2004 21:15:49 -0500

Thanks, Perry -

That did help quite a bit. I didn't realize that Jpegs contained DPI information!

On Nov 3, 2004, at 6:41 PM, Perry Clarke wrote:

On Nov 3, 2004, at 12:02 PM, Michael Heinz <email@hidden> wrote:

I'm taking the default settings for NSImageView, including proportional scaling but some images not only do not scale to fill the window they are getting rendered at only a few percent of their "real" size - even if I go and modify the NIB so that NSImageView is set to not scale at all.

The images in question probably have a DPI of something other than that of the screen. You'll need to resize the images to make them appear "full size" on your display.


Something like this should do the trick:

    NSImageRep *myRep = [[image representations] objectAtIndex:0];

    // note that these aren't necessarily identical.
    float hres = [myRep pixelsWide]/[image size].width;
    float vres = [myRep pixelsHigh]/[image size].height;

// If the resolution isn't 1.0 (i.e. 72dpi) we must resize the image to its pixel dimensions
// to get the desired size
if (hres != 1.0 || vres != 1.0)
{
[image setSize:NSMakeSize((float)[myRep pixelsWide], (float)[myRep pixelsHigh])];
}


The images seem to behave appropriately in Preview.

It's unwise to think of Preview as a simple wrapper around NSImageView (even more dangerous to let one's manager think of it as that :-)


Also - how do I manually change the scale of the image the way Preview can?

Again, you need to set the size of the underlying image appropriately.

Perry

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


This email sent to email@hidden

_______________________________________________ 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
References: 
 >Re: Lame problem with NSImageView (From: Perry Clarke <email@hidden>)

  • Prev by Date: Re: Multiple Documents?! [newbie] [again]
  • Next by Date: Re: How do I include a library in my program
  • Previous by thread: Re: Lame problem with NSImageView
  • Next by thread: Re: Updating /etc/hostconfig
  • Index(es):
    • Date
    • Thread