1

I am trying to convert 10 UIImages in .gif format programatically using IOS Xcode 4.5 and save it in gallery, but am having no luck I even tried a question at stackoverflow Create and and export an animated gif via iOS? I am not getting the point what are the variables like __bridge id used and how can i assign these images to the method please help ....

Community
  • 1
  • 1
naughty
  • 35
  • 1
  • 6

2 Answers2

1

instead of converting image in to Gif apple provide UIImageView.animationImages proparty that you can Animation Number of images one by one like gif. like Bellow code:-

UIImage *statusImage = [UIImage imageNamed:@"status1.png"];
    YourImageView = [[UIImageView alloc]
                                      initWithImage:statusImage];


    //Add more images which will be used for the animation
    YourImageView.animationImages = [NSArray arrayWithObjects:
                                         [UIImage imageNamed:@"status1.png"],
                                         [UIImage imageNamed:@"status2.png"],
                                         [UIImage imageNamed:@"status3.png"],
                                         [UIImage imageNamed:@"status4.png"],
                                         [UIImage imageNamed:@"status5.png"],
                                         [UIImage imageNamed:@"status6.png"],
                                         [UIImage imageNamed:@"status7.png"],
                                         [UIImage imageNamed:@"status8.png"],
                                         [UIImage imageNamed:@"status9.png"],
                                         nil];




         //setFrame of postion on imageView

          YourImageView.frame = CGRectMake(
                                     self.view.frame.size.width/2
                                     -statusImage.size.width/2, 
                                     self.view.frame.size.height/2
                                     -statusImage.size.height/2, 
                                     statusImage.size.width, 
                                     statusImage.size.height);


  YourImageView.center=CGPointMake(self.view.frame.size.width /2, (self.view.frame.size.height)/2);


      YourImageView.animationDuration = 1;
      [self.view addSubview:YourImageView];
Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
  • Thanks Nitin but in my project i am working to save the image and i don't want animation on the view i would rather upload the gif image on my servers using webservices – naughty Jun 08 '13 at 06:46
-2

First of all you should check for your problem in Apple Documentation. Everything is given there. What you need is to Research & Read.

You should try the ImageIO framework. It can convert .png files into CGImageRef objects and then export the CGImageRefs to .gif files.

To save Images to Photo Library :UIImageWriteToSavedPhotosAlbum(imageToSave, nil, nil, nil); Also Documented in UIKit.

Bhavin
  • 27,155
  • 11
  • 55
  • 94
  • Just one more thing vin here i am saving with the path NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"animated.gif"]; what's the path for gallery as this is saved in the documents folder – naughty Jun 08 '13 at 07:02
  • @naughty : What do you mean by "gallery" ? – Bhavin Jun 08 '13 at 07:03
  • the picturegallery folder used where all the pictures are saved when we click from camera or photos in iphone – naughty Jun 08 '13 at 07:04
  • @naughty : `UIImageWriteToSavedPhotosAlbum(imageToSave, nil, nil, nil);` – Bhavin Jun 08 '13 at 07:07
  • Iam using something like CGImageDestinationSetProperties(destination, (CFDictionaryRef)gifProperties); CGImageDestinationFinalize(destination); CFRelease(destination); to save the gif image and if i save the image using UIImageWriteToSavedPhotosAlbum it would save a still image – naughty Jun 08 '13 at 07:11
  • @naughty : Take a look at : http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIKitFunctionReference/Reference/reference.html – Bhavin Jun 08 '13 at 07:13
  • Thanks Brother i would do that but thanks a tons for the help ;) – naughty Jun 08 '13 at 07:15