Re: NSImage/BitmapRep behavior
Re: NSImage/BitmapRep behavior
- Subject: Re: NSImage/BitmapRep behavior
- From: Shawn Erickson <email@hidden>
- Date: Sat, 23 Dec 2006 08:53:29 -0800
On Dec 23, 2006, at 8:26 AM, Ben Zotto wrote:
Hi all,
I'm hoping someone can help me understand the following behavior so
I can better understand what's happening in some of my image
management code.
I load a large JPEG (pretty standard, from a digital camera) into
an NSImage via -initWithContentsOfFile:. The JPEG has a resolution
of 2592 x 1944. This is the same as the pixelsWide/pixelsHigh
given by the NSBitmapImageRep representation. I have not yet drawn
the NSImage into anything, so it has not yet become a cached image.
But the -size method on NSImage returns a size of
1036.800049x777.599976. Why? This size doesn't seem to be some
multiple of the pixel resolution of the image (or any relation to
the size of the view which it will later be drawn into).
I ran some NSLogging on the NSImage and its reps before and after
drawing the image. Here are the results:
****
NSImage size: 1036.800049 x 777.599976
rep: NSBitmapImageRep 0x3568b0 Size={1036.8, 777.6}
ColorSpace=NSCalibratedRGBColorSpace BPS=8 BPP=24 Pixels=2592x1944
Alpha=NO Planar=NO Format=0
NSImageRep pix: 2592 x 1944
NSImages define size in terms of user space coordinates which is 72
points per inch. NSBitmapImageReps & NSCachedImageReps define size in
terms of pixels.
The difference you see between NSImage size and the size returned by
NSBitmapImageRep comes from the DPI information imbedded in the image
you are opening. In this case the source image appears to be set to
180 DPI.
user space: 72 DPI (dots per inch)
image space: 180 DPI
NSImage wants one inch of image to be one inch when displayed so...
180 / 72 = 2.5
1036.8 x 2.5 = 2592
777.6 x 2.5 = 1944
-Shawn
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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