2014-05-15 48 views
1

我已經能夠在固態JPG切換的iPhone 3GS上獲得將近10 FPS,但我已經看到GPU和CALayer可能會更快。你能幫我確定如何做到這一點?我已經嘗試了一些下面的各種東西。如何在iOS上實現JPG圖像顯示的快速幀速率?

下面是我一直使用的是什麼...

#define FPS 12.0 

[NSTimer scheduledTimerWithTimeInterval:(1.0/FPS) target:self selector:@selector(animateMethod:) userInfo:nil repeats:YES]; 

請注意baseImagePath每個調用返回不同的路徑方法。

- (void)animateMethod:(NSTimer *)timer 
{ 
    self.imageView.image = [UIImage imageWithContentsOfFile:[self baseImagePath]]; 
} 

這裏就是我已經試過......

- (void)animateMethod:(NSTimer *)timer 
{ 
    self.layerView.layer.contents = [(__bridge id)([[UIImage imageWithContentsOfFile:[self baseImagePath]] CGImage]); 
} 

回答

0

我想你可以從不同的角度來處理這個以達到你想要的結果。您可以利用UIImageView的動畫屬性來完成此操作。您可以首先按照您希望它們在動畫中顯示的順序將圖像預加載到數組中。然後設置你的UIImageView

NSMutableArray *images = [NSMutableArray array]; 
for (int i = 0; i < 16; i++) { 
    UIImage *image = [UIImage imageNamed: [NSString stringWithFormat: @"image_%d.jpg", i]]; 
    [images addObject: image]; 
} 

[self.myImageView setAnimationImages: images]; 
[self.myImageView setAnimationDuration: 0.5];  // Image view will loop through all images in half a second. 
[self.myImageView setAnimationRepeatCount: 0]; // Infinite looping 
[self.myImageView startAnimating];