• 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 02:18:00 +0200

That's strange. When I'm doing this, it scale properly (but it's slow).

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

NSRect src = NSMakeRect(0, 0, [gSticky size].width, [gSticky size].height);
[gSticky drawInRect:[self bounds] fromRect:src operation:NSCompositeSourceOver fraction:1];
}


It look like this pdf is rather heavy to draw. Even when I open it in Preview (on a 2.2 Ghz Core 2 Duo) it need some times to display it.

Le 6 avr. 08 à 01:45, Mike R. Manzano a écrit :
Unfortunately, that still didn't work. The resultant images continue to be pixelated, as you can see here:

http://instantvoodoomagic.com/stickycapture.png

In my window's -awakeFromNib:

gStickyImage = [NSImage imageNamed:@"sticky.pdf"] ;
[gStickyImage setDataRetained:YES] ; // Setting this to NO doesn't seem to make a difference
[gStickyImage setCacheMode:NSImageCacheNever] ;


In -drawRect:

	NSRect stickyBounds ;
	// [gStickyImage setScalesWhenResized:YES] ;
	// [gStickyImage setSize:[self bounds].size] ;
	stickyBounds.size = [gStickyImage size] ;
	stickyBounds.origin.x = stickyBounds.origin.y = 0.0f ;
	[gStickyImage	drawInRect:[self bounds]
				fromRect:stickyBounds
				operation:NSCompositeSourceAtop
				fraction:1.0f] ;

If I uncomment the two lines in -drawRect:, the sticky is rendered sharply, but as I noted before, it takes a long time to scale:

http://instantvoodoomagic.com/stickycapture2.png

Here's the original PDF:

http://instantvoodoomagic.com/sticky.pdf

Thanks for the suggestions so far. If I figure it out, I'll post my solution.

Mike


On Apr 5, 2008, at 11:59 AM, Jean-Daniel Dupas wrote:

This is because Cocoa cache the first representation it draws and then redraw the cached version.

Disabling the cache for your image should do the trick:

[_img setCacheMode:NSImageCacheNever];

Le 5 avr. 08 à 20:26, Mike R. Manzano a écrit :
I did try that at first, but the image becomes pixelated when you make the window larger. What I'm trying now is to do an initial scale of the image to some large dimensions, and then doing what you suggested. Maybe it will look fine if the only scaling it has to do is in the downwards direction.

Mike


_______________________________________________

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


_______________________________________________

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: "Mike R. Manzano" <email@hidden>
References: 
 >Scaling a window background image quickly (From: "Mike R. Manzano" <email@hidden>)
 >Re: Scaling a window background image quickly (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Scaling a window background image quickly (From: "Mike R. Manzano" <email@hidden>)
 >Re: Scaling a window background image quickly (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Scaling a window background image quickly (From: "Mike R. Manzano" <email@hidden>)

  • Prev by Date: Re: Place NSView into NSView
  • 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