Re: How do I make a screensaver that draws pictures?
Re: How do I make a screensaver that draws pictures?
- Subject: Re: How do I make a screensaver that draws pictures?
- From: Andreas Monitzer <email@hidden>
- Date: Mon, 31 Dec 2001 00:30:42 +0100
On Sunday, December 30, 2001, at 11:54 , Taxxodium wrote:
- (void)animateOneFrame
{
NSImage *image;
NSRect myRect;
NSSize mySize;
image = [[NSImage imageNamed:@"mypict.jpg"] copy];
mySize = [image size];
myRect.origin.x = 0;
myRect.origin.y = 0;
myRect.size = mySize;
[image lockFocus];
[image drawInRect:[self bounds] fromRect:myRect
operation:NSCompositeCopy fraction:0.5];
[image unlockFocus];
}
Cool, you're leaking one image per frame (one copy and no release)! I'd
rather suggest loading the picture in the initializer and releasing it
in the dealloc method, which should be much faster, too (since you're
only loading it once).
andy