• 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: Scaling a window background image quickly
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scaling a window background image quickly


  • Subject: Re: Scaling a window background image quickly
  • From: Heinrich Giesen <email@hidden>
  • Date: Sun, 6 Apr 2008 10:50:30 +0200


Hi,
your PDF image is a beast, its size is 624 kB and contains a lot of complicated structures.
I converted the PDF into an equivalent (same size and with alpha) PNG- file with only 28 kB.
But that is only important for the first drawing where an NSImage with only one representation
(NSPDFImageRep) is created and rendered. For the following drawings there is not a big difference.


In your code you use:
[gStickyImage setCacheMode:NSImageCacheNever] ;

This is deadly and makes it slow, because rendering starts from scratch, the PDF-file, not from the NSImage object.


For a sharp (not pixelated) image you need to setDataRetained:YES. This is explained in the docs
(NSImage -> -setDataRetained: ) and was discussed alot in this list.


Using Jean-Daniel's code snippet as a starting point I tried this with success (sharp and fast):

- (void)drawRect:(NSRect)aRect {
   if (!gSticky) {
     gSticky = [NSImage imageNamed:@"sticky"];
     [gSticky setDataRetained:YES];
   }

   [gSticky drawInRect:[self bounds] fromRect:NSZeroRect
       operation:NSCompositeSourceOver fraction:1];
}

You may also set the imageInterpolation to NSImageInterpolationHigh, but only if
you are not in the state of "inLiveResize"


    Heinrich

--
Heinrich Giesen
email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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


  • Follow-Ups:
    • Re: Scaling a window background image quickly
      • From: Jean-Daniel Dupas <email@hidden>
  • Prev by Date: Re: to store item pointer in NSButtonCell's subclass in NSOutlineView implementation
  • Next by Date: Re: Scaling a window background image quickly
  • Previous by thread: Re: Scaling a window background image quickly
  • Next by thread: Re: Scaling a window background image quickly
  • Index(es):
    • Date
    • Thread