• 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: Jean-Daniel Dupas <email@hidden>
  • Date: Sun, 6 Apr 2008 12:41:39 +0200


Le 6 avr. 08 à 10:50, Heinrich Giesen a écrit :

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

The main advantage of PDF (and vector graphic in general) is that there should not be any interpolation. By using PNG, you lose all benefits of resolution independant graphics.
This works well with lightweight PDF, but apparently not for complex one.


As suggested, the way to go is probably to ignore pixelisation during resizing, and when the resizing is over, recreate a cache image from the PDF rep. I don't know the best way to do it, but this should probably works:

[NSImage setScalesWhenResized:YES];
[NSImage setSize:finalSizeAfterResizing];


_______________________________________________

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: "Kyle Sluder" <email@hidden>
References: 
 >Re: Scaling a window background image quickly (From: Heinrich Giesen <email@hidden>)

  • Prev by Date: Re: Scaling a window background image quickly
  • Next by Date: Re: how to hack my own apps
  • Previous by thread: Re: Scaling a window background image quickly
  • Next by thread: Re: Scaling a window background image quickly
  • Index(es):
    • Date
    • Thread