display and create gif image on iPhone - iphone

I am googling for the answer from last few hours. I know that Apple and Facebook do not support gif images, I wants to display and create gif image in an iPhone App, I find the alternate solution that make the image sequence and give animation. I wants to create the GIF image from these images and post on Facebook wall.
When I was googling about Facebook and Apple, it shows 2 years old answers. May be now apple and Facebook changed their policies, Is this possible to create GIF image on iPhone App and post to it on Facebook?
According to this stack overflow question here does Apple support gif images?
UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
animatedImageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:#"image1.gif"],
[UIImage imageNamed:#"image2.gif"],
[UIImage imageNamed:#"image3.gif"],
[UIImage imageNamed:#"image4.gif"], nil];
animatedImageView.animationDuration = 1.0f;
animatedImageView.animationRepeatCount = 0;
[animatedImageView startAnimating];
[self.view addSubview: animatedImageView];

I've been able to create animated gifs on iOS using ImageMagick. There are a number of tutorials out there. Here is one. And here is ImageMagick compiled for iOS.
What I wasn't able to sort out (due to time) was how to get the benefit of compression by using palettized images and other gif compression methods. That wold be something to look into as I found the images I was able to create were quite large.

Related

How to implement the welcome page animation of appflow

Below image is from AppFlow welcome page animation.
Not launch image, this is just part of welcome page , part of.... not all welcome page and I can't show the animation here, so I screen shot some frames of this animation and rearrange here.
I am sure that is not a gif or any image animation, should finished by objc code. Anyone could give me some thread or sample code will be great!
Thanks
There are plenty of ways of displaying animations in iOS. For the animation you described above, I would recommend making one PNG image per frame. Then you can display the animation in a UIImageView similar to below:
imageView.animationImages = [NSArray arrayWithObjects:[UIImage imageNamed:#"1.png"], [UIImage imageNamed:#"2.png"], nil];
imageView.animationDuration = 1;
imageView.animationRepeatCount = 0;
[imageView startAnimating];
Place the UIImageView on the welcome view controller.

Animate Logo just like Skype iPad App

I am building a application I need to animate logo just like skype application. I am still not sure how to get the affect skype logo appear while starting the application
As far as my understanding on your question, you can try using frame images (frames of gif images to be precise )on UIImageView.
NSArray * imageArray = [[NSArray alloc] initWithObjects:[UIImage imageNamed:#"1.png"], [UIImage imageNamed:#"2.png"], nil]; //this will be the frames of animation images in sequence.
ringImage = [[UIImageView alloc]initWithFrame:CGRectMake(100,200,600,600)];
ringImage.animationImages = imageArray;
ringImage.animationDuration = 1.5;//this the animating speed which you can modify
ringImage.contentMode = UIViewContentModeScaleAspectFill;
[ringImage startAnimating];//this method actually does the work of animating your frames.
To STOP the animation, just use [ringImage stopAnimating];
Do let me know if this answers your question:)
Hey I just find out this example using MCSpriteLayer...
You can go through this link...
Also they have downloadable link Here
This solved my purpose hope this will help you guys too

Best approach for integrating custom graphics in iOS development

What are the best references to read (online resources or books) to read about the approaches and techniques for integrating custom images, graphics, icons for iOS apps? (What are the best strategy to manage custom images for iOS development?)
Uh, ok, not sure if you need super high level OpenGL graphics performance but if you're making ordinary iPhone apps (not games), then maybe these starter knowledge can guide you.
This is from my own limited experience but there are two types of graphics that I distinguish: graphics that are packaged with the app and graphics that are loaded through some network or file on the device.
For graphics that are packaged with the app, these tend to be the buttons and backgrounds for the look and feel of an app.
With these kind of graphics, to display an image to your application, the general idea is you create a UIImageView then add it as a subview of your View Controller's view. You then tell your image view object the image you want to display.
// create the image view object to display the image
UIImageView *myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,100,100)];
// tell the image view object the image you want to display
[myImageView setImage:[UIImage imageNamed:#"mybutton.png"]];
// add the image view object to your view controller's view
[self.view addSubview:myImageView];
[myImageView release];
As for network images, I usually get the URL of the image I want to display, then use a image caching library such as SDWebImage to load the image like so:
NSURL *url = [[NSURL alloc] initWithString:#"http://www.mysite.com/images/myphoto.png"];
[myImageView imageWithURL:urlOfImage placeholder:[UIImage imageNamed:#"placeholder.png"]];
[url release];
How you get the URL path to your image from the network is a different matter though. If you're loading through a web service, you usually have to fetch it from the JSON or XML output.

Which animated file types are supported by iOS?

I just want to add an animated file to my application.
Most of the postings I have read, are using UIImageViews or collection of the multiple images. I don't want to do that.
I just want to know which animated file formats are working on iOS (I know .gif and .swf are not working on iOS).
So is there any other file format, which I can use in my app OR let me know if there is any other framework to use the animated file.
You may use gif. You need to show inside UIWebView.
we cant use any animated file like .gif, .swf because apple not allows us. if you want to animate the images just do that way.
UIImageView* campFireView = [[UIImageView alloc] initWithFrame:self.view.frame];
// load all the frames of our animation
campFireView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:#"campFire01.png"],
[UIImage imageNamed:#"campFire02.png"],
[UIImage imageNamed:#"campFire03.png"],
[UIImage imageNamed:#"campFire04.png"],
[UIImage imageNamed:#"campFire05.png"],
[UIImage imageNamed:#"campFire06.png"],
[UIImage imageNamed:#"campFire07.png"],
[UIImage imageNamed:#"campFire08.png"],
[UIImage imageNamed:#"campFire09.png"],
[UIImage imageNamed:#"campFire10.png"],
[UIImage imageNamed:#"campFire11.png"],
[UIImage imageNamed:#"campFire12.png"],
[UIImage imageNamed:#"campFire13.png"],
[UIImage imageNamed:#"campFire14.png"],
[UIImage imageNamed:#"campFire15.png"],
[UIImage imageNamed:#"campFire16.png"],
[UIImage imageNamed:#"campFire17.png"], nil];
// all frames will execute in 1.75 seconds
campFireView.animationDuration = 1.75;
// repeat the annimation forever
campFireView.animationRepeatCount = 0;
// start animating
[campFireView startAnimating];
// add the animation view to the main window
[self.view addSubview:campFireView];
or see that link www.appsamuck.com/day2.html
By default a GIF won't animate correctly in a UIImageView. However, with a little extra effort you can get them to work.
This project looks the most promising as it appears to actually decode the gif and display the individuals frames for you.
https://github.com/arturogutierrez/Animated-GIF-iPhone/
Otherwise, the other solutions I've seen are what you mentioned. (Separating the gif into multiple images manually)
http://www.alterplay.com/ios-dev-tips/2010/12/making-gif-animating-on-ios.html
You can use cocos2D for this animation. Use with CCSpriteSheet.

Memory Management

I need a clarification from all of you,That is I am implementing an iPad application. In that I tried to download and animate the images. The image count should be more than 100,000.The code I used to download and adding to the view is as follows.
UIImageView* imageView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0,100,100)];
NSData *receivedData=nil;
receivedData = [NSData dataWithContentsOfURL:[NSURL URLWithString:#"http://path/prudently/iphone/image_s/e545afbf-4e3e-442e-92f9-a7891fc3ea9f/test.png"]];
imageView.image = [[UIImage alloc] initWithData:receivedData] ;
[subView addSubview:imageView];
[imageView release];
But I am getting exception after I successfully added more than 8000 image to my subview. I am getting exception at getting data from the url. And one more thing I am not releasing the subview because once I downloaded them I need to animate the subview.
Please give me your suggessions
Thank you,
Sekhar Bethalam.
100,000 images would seem a lot for desktop applications, let alone a smart phone like an iPhone. Is there not another approach you can take to solve this problem that wouldn't need such a high resource count?
You can write the URL , images or something to a cached file, and divide some pages to animate the images...
When the user press a page link , application read and animate the images of this page, images of the page which user don't use need not display.
The only way you are going to accomplish this is to dynamically create and destroy the UIImageViews as they are needed on the screen. The iPhone/iPad/iAnything are incapable of doing what you want because of the limited memory available on the device.