3

By extracting .gif image,i got 48 frames with resolution of (1024*768). And i Stored those frames in a Array like this.

NSMutableArray *splashImages = [[NSMutableArray alloc] init];
    for(int i=1;i <= 48;i ++)
    {
        [splashImages addObject:[UIImage imageNamed:[NSString  stringWithFormat:@"img%d.jpg",i]]];
    }
    [ImageView setAnimationImages:splashImages];
    [ImageView setAnimationDuration:1.0];
    [ImageView startAnimating];

And i gave this to UIImageView with duration of 1s,By running application,it went out like smoothless animating and even it getting stuck.

Any Solution for this?

Vedchi
  • 1,200
  • 6
  • 14

2 Answers2

1

Before all, I am afraid that may cause memory warning if you load all 48 images in to memory, check it with Instrument.

================================

You probably need to force it do the decompressing and rendering before, check this link1 and this link2

Try this, it causes the image to decompress, even though the image context is just 1 pixel large.:

UIGraphicsBeginImageContext(CGSizeMake(1, 1));
    [decompressedImage drawAtPoint:CGPointZero];
UIGraphicsEndImageContext();

or something like this:

CGDataProviderRef imageDataProvider = CGDataProviderCreateWithCFData((__bridge CFDataRef)imageData);
    CGImageRef image = CGImageCreateWithJPEGDataProvider(imageDataProvider, NULL, NO, kCGRenderingIntentDefault);
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef bitmapContext = CGBitmapContextCreate(NULL, CGImageGetWidth(image), CGImageGetHeight(image), CGImageGetBitsPerComponent(image), 0, colorSpace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little);
    CGColorSpaceRelease(colorSpace);
    CGContextDrawImage(bitmapContext, CGRectMake(0, 0, CGImageGetWidth(image), CGImageGetHeight(image)), image);

    CGDataProviderRelease(imageDataProvider);
    CGContextRelease(bitmapContext);

    if (image){
        decompressedImage = [UIImage imageWithCGImage:image];
        CGImageRelease(image);
    }

Hope this is helpful.

Community
  • 1
  • 1
swang
  • 250
  • 1
  • 11
0

You approach is not going to work. See how-to-resolve-memory-crash-in-iphone and loading-images-for-animation-in-uiimageview-ios for some examples of problems you will run into. You would be better off just encoding a movie in h.264 and playing it with AVPlayer. That is a far better approach than creating a bunch of full screen .gif files.

Community
  • 1
  • 1
MoDJ
  • 4,309
  • 2
  • 30
  • 65