Re: Scaling a window background image quickly
Re: Scaling a window background image quickly
- Subject: Re: Scaling a window background image quickly
- From: "Mike R. Manzano" <email@hidden>
- Date: Sat, 5 Apr 2008 23:24:46 -0700
Looks like the key difference was that I was using
operation:NSCompositeSourceAtop instead of NSCompositeSourceOver. For
whatever reason, it doesn't pixelate with NSCompositeSourceOver.
Unfortunately, it's still slow. I guess I'll have to go back to the
drawing board on the PDF.
Thanks for all the help!
Mike
On Apr 5, 2008, at 5:18 PM, Jean-Daniel Dupas wrote:
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