Re: Compositing Tricks?
Re: Compositing Tricks?
- Subject: Re: Compositing Tricks?
- From: Jerry LeVan <email@hidden>
- Date: Sun, 11 Jul 2004 18:56:28 -0400
I tried a variety of repeat times and zoom/fade factors.
The bottom line seemed to be, not surprisingly, big pics=>jerky
response.
Part of the problem is that the program will process all of the
images in a directory, from tiny to huge.
createScaledImage does always start with the original image and
scales/rotates/fades
as necessary. I will take a closer look and see if I can make some
optimizations...
I have a "reflect" mode that always reflects the image in the display
ie several
reflections in a row may be performed on the same image, it make for
fuzzy pictures
very quickly (this is why most modes start with the original image).
Jerry
On Jul 11, 2004, at 6:27 PM, Shawn Erickson wrote:
On Jul 11, 2004, at 2:53 PM, Jerry LeVan wrote:
I cobbled together a little app so I could try some zoomin' and fadin'
to see how it would look...
Code basically looks like:
*****************************************
-(void) performZoom
{
targetZoom = [theSlider floatValue];
zoomAmount = 0.1;
[theSlider setFloatValue:zoomAmount];
timer = [[NSTimer scheduledTimerWithTimeInterval:0.0025
target:self selector:@selector(zoomNextImage:)
userInfo: nil
repeats:YES] retain];
}
// Start with a small image and progressively draw larger...
-(void)zoomNextImage:(id)sender
{
float amt = [theSlider floatValue];
if(amt > targetZoom)
{
[timer invalidate];
[timer release];
[theSlider setFloatValue: targetZoom];
return;
}
amt = amt + 0.1;
[theSlider setFloatValue: amt]; // set how much to zoom the
image
[self createScaledImage:theImage]; // build the image...
}
Code for the "fade in" is very similar.
Works ok for small images ( about the size of you hand ) but the
bigger
images display sorta herky jerky. I have a 933 quicksiver.
Is there a clever way I can speed up the display or is NSImage
basically
too "clunky"? (maybe a 3.0GHZ Dualie would help :)
Why are you firing the timer so often? You are trying to do things at
400 frames per second when 15 or 30 FPS should be more then enough.
I would pick a frame rate and an overall time to zoom then use math on
that and the target zoom value to pick appropriate zoom steps that you
use when the timer fires.
Also I note that createScaledImage: method sure sounds like it creates
new images, hence over and over again as the timer fires. It would be
more efficient just to draw the image at the scaled size instead of
recreating a new again and again. This would allow Quartz to
potentially optimize things far better because you are reusing the
same image but simply with a different scaling factor.
As a side note... If you ever are wondering why something is not
performing very well I strongly suggest using Shark to try to
understand why (part of Apple CHUD tools).
-Shawn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.