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

Re: NSImage initWithContentsOfURL


  • Subject: Re: NSImage initWithContentsOfURL
  • From: Matt Judy <email@hidden>
  • Date: Wed, 23 Jan 2002 17:30:02 -0800

John Nikolai wrote:
>
> image = [[NSImage alloc] initWithData:[url resourceDataUsingCache:YES]];
>
> Note that initWithData: is not a class method. At least not in the
> current framework I have installed.

Right, right. My code used to make those calls, but I changed things around a bit... If you're working with online images, you're eventually going to find that, if you load an image from the web whose resolution is higher than 72 dpi, AppKit will draw that image at the higher resolution, making it appear too small on your display.

The workaround for that problem is to use an NSBitmapImageRep, like this:

// ------------------------------------------------------------------
NSURL *url = [NSURL URLWithString:stringURLOfHiRezImage];

NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithData:
[url resourceDataUsingCache:YES]];
NSImage *image = [[NSImage alloc] initWithSize:[comicImageBitmapRep size]];

[image addRepresentation:imageRep];
// ------------------------------------------------------------------

Now your image will be sized properly.

--Matt Judy


References: 
 >Re: NSImage initWithContentsOfURL (From: John Nikolai <email@hidden>)

  • Prev by Date: Re: NSImage initWithContentsOfURL
  • Next by Date: re: Perl
  • Previous by thread: Re: NSImage initWithContentsOfURL
  • Next by thread: NSTabView without tabs
  • Index(es):
    • Date
    • Thread