Re: NSImage question
Re: NSImage question
- Subject: Re: NSImage question
- From: "Oscar Bascara" <email@hidden>
- Date: Fri, 25 May 2007 22:44:01 -0700
Thanks! I got some great responses by e-mail. Here is what gets it
to work. First, I should not get the size using:
size = [imageRep size];
since it gives point size (1 point = 1/72 inch). Instead, I should use:
size = NSMakeSize([imageRep pixelsWide], [imageRep pixelsHigh]);
to get pixel size. These sizes are the same if the image is 72 dpi.
But the image I am drawing is actually 100 dpi, not 72 dpi, which
resulted in the weird, smaller display size.
Second, to prevent the loss of image quality after rescaling, I need
to set the cache mode:
[image setCacheMode:NSImageCacheNever];
Question: What is the performance hit in not caching the image?
Oscar
On 5/24/07, Oscar Bascara <email@hidden> wrote:
Hi All,
Here is an NSImage puzzle. I've got an image that I dragged from a
web page to the desktop. The image gets saved as a jpg file, but it's
behaving strangely. In Preview, the jpg file displays fine. It has
size 180 x 240 (just as it is shown in the web page). But then I try
to display the image in a program a usual way:
image = [NSImage imageNamed:@"image_file"];
[image compositeToPoint:point operation:NSCompositeSourceOver];
The image is drawn smaller for some reason. Checking the image
representation size, I get 129.6 x 172.8. Also, the image quality is
not as good, especially if I try rescaling it to 180 x 240. Viewing
the image in the Xcode editor, by the way, also gives this weird,
smaller display size. Somehow Preview knows how to display the image
correctly.
Any idea what is going on?
Oscar
_______________________________________________
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