• 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: can a Cocoa app scale jpeg images as nicely as Preview does?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: can a Cocoa app scale jpeg images as nicely as Preview does?


  • Subject: Re: can a Cocoa app scale jpeg images as nicely as Preview does?
  • From: Mike Morton <email@hidden>
  • Date: Fri, 7 Oct 2005 12:30:25 -0400

Ali et alia --

This worked great.

Googling for setImageInterpolation:, I found <http://www.cocoadev.com/index.pl?ThumbnailImages>. Of the techniques there, I found that I had to use drawInRect:... -- compositing didn’t work for me.

I wound up doing:

NSImage *result = [[[NSImage alloc] initWithSize: newSize] autorelease];
[result lockFocus];
[[NSGraphicsContext currentContext] setImageInterpolation: quality];
[self drawInRect: NSMakeRect (0, 0, newSize.width, newSize.height)
fromRect: NSMakeRect (0, 0, currentSize.width, currentSize.height)
operation: NSCompositeCopy
fraction: 1.0];
[result unlockFocus];


Thanks!

-- Mike


On Oct 6, 2005, at 4:02 PM, Ali Ozer wrote:

You can get better scaling via -[NSGraphicsContext setImageInterpolation:NSImageInterpolationHigh].
Ali




Begin forwarded message:

From: Mike Morton <email@hidden>
Date: October 6, 2005 9:34:33 AM PDT
To: Cocoa-Dev <email@hidden>
Subject: can a Cocoa app scale jpeg images as nicely as Preview does?

Folks --

When I load a jpeg image into my app and shrink it, certain images look pretty awful. When I open the same image in Preview and Zoom Out a bunch of times, it briefly looks awful, but then it sharpens up and looks great.

For example, try grabbing <http://images.amazon.com/images/P/B000006TRV.01._SCLZZZZZZZ_.jpg> and doing Zoom Out six times, scaling it down 8x in each dimension. You can almost read the text.

When I scale that image by the same amount in a simple Cocoa app (by resizing the NSImage or by making the NSImageView the right size), it comes out pretty ugly


I’m sure there are techniques and libraries out there to do this, but I thought NSImage would do a good job right out of the box...


Thanks,

-- Mike

_______________________________________________
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: 
 >can a Cocoa app scale jpeg images as nicely as Preview does? (From: Mike Morton <email@hidden>)
 >Re: can a Cocoa app scale jpeg images as nicely as Preview does? (From: Ali Ozer <email@hidden>)

  • Prev by Date: Re: How to release Cocoa objects from Perl? (PerlObjCBridge or CamelBones)
  • Next by Date: Printing multiple pages using drawRect: (SOLVED)
  • Previous by thread: Re: can a Cocoa app scale jpeg images as nicely as Preview does?
  • Next by thread: Flipping an NSImage
  • Index(es):
    • Date
    • Thread