简体   繁体   English

如何将动画图像保存到iPhone的相册中?

[英]How to save an animated image to iPhone's photos album?

I created an animated image, and it animates properly in an UIImageView: 我创建了一个动画图像,并在UIImageView中正确设置了动画:

- (void)viewDidLoad
{
    [super viewDidLoad];
    UIImage *image1 = [UIImage imageNamed:@"apress_logo"];
    UIImage *image2 = [UIImage imageNamed:@"Icon"];
    UIImage *animationImage = [UIImage animatedImageWithImages:[NSArray arrayWithObjects:image1, image2, nil] duration:0.5];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    imageView.image = animationImage;
    [self.view addSubview:imageView];
}

But if saved to photos album, it couldn't animate agian: 但是,如果将其保存到相册中,则无法为阿吉安人制作动画:

UIImageWriteToSavedPhotosAlbum(animationImage, 
                               self,
                               @selector(imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:),
                               nil);

So is there any solution to save an animated image to photos album? 那么,有什么解决方案可以将动画图像保存到相册吗?

Special thanks! 特别感谢!

The photo album is an application as well, like exactly what you are making. 相册也是一个应用程序,就像您正在制作的一样。 Except to animate an image you wrote corresponding code like, 除了为图像制作动画以外,您还编写了类似的代码,

UIImage *animationImage = [UIImage animatedImageWithImages:[NSArray arrayWithObjects:image1, image2, nil] duration:0.5];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    imageView.image = animationImage;

But you assumed that your Image will be treated in similar way inside your photo album app as well. 但您假设相册应用程序中的图像也会得到类似处理。 Then No thats not true. 然后,那不是真的。 in photo album app probably the application just reading an Image from disk and then shows in inside UIImageView without any animation "BECAUSE THERE IS NO ANIMATION CODE" :) 在相册应用程序中,该应用程序可能只是从磁盘读取图像,然后在UIImageView中显示而没有任何动画“因为没有动画代码” :)

This creates an opportunity to create a photo album with animated images. 这为创建带有动画图像的相册提供了机会。


I have seen programs like Quartz Composer creating .mov file from several images and creating animations to it. 我见过像Quartz Composer这样的程序,它从多个图像创建.mov文件,并为其创建动画。 But thats professionally built by Apple. 但这就是Apple专业打造的。 Now, I said because I think it's possible to create .mov by using API but you might have to dig deeper as I have no idea how to. 现在,我说这是因为我认为可以通过使用API​​创建.mov,但是您可能不得不更深入地研究,因为我不知道该怎么做。

The closest reference I can find is this : 我能找到的最接近的参考是:

http://www.cimgf.com/2008/09/10/core-animation-tutorial-rendering-quicktime-movies-in-a-caopengllayer/ http://www.cimgf.com/2008/09/10/core-animation-tutorial-rendering-quicktime-movies-in-a-caopengllayer/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM