• 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: Compositing Tricks?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compositing Tricks?


  • Subject: Re: Compositing Tricks?
  • From: Shawn Erickson <email@hidden>
  • Date: Sun, 11 Jul 2004 15:27:55 -0700

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.


  • Follow-Ups:
    • Re: Compositing Tricks?
      • From: Jerry LeVan <email@hidden>
References: 
 >Re: Compositing Tricks? (From: Jerry LeVan <email@hidden>)

  • Prev by Date: Re: What's better a separate run loop or separate thread?
  • Next by Date: Re: Fullscreen application choices
  • Previous by thread: Re: Compositing Tricks?
  • Next by thread: Re: Compositing Tricks?
  • Index(es):
    • Date
    • Thread