Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在IOS中制作动画gif图像_Ios_Nsdata_Animated Gif - Fatal编程技术网

如何在IOS中制作动画gif图像

如何在IOS中制作动画gif图像,ios,nsdata,animated-gif,Ios,Nsdata,Animated Gif,我正在尝试在iOS中制作动画gif裁剪器 我使用的是cgmagedestinationref 这是我的密码: NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:nil]; NSURL *fileURL = [documen

我正在尝试在iOS中制作动画gif裁剪器

我使用的是
cgmagedestinationref

这是我的密码:

NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:nil];
NSURL *fileURL = [documentsDirectoryURL URLByAppendingPathComponent:@"animated.gif"];

CGImageDestinationRef destination = CGImageDestinationCreateWithURL((__bridge CFURLRef)fileURL, kUTTypeGIF, imageCount, NULL);
CGImageDestinationSetProperties(destination, (__bridge CFDictionaryRef)fileProperties);

for (size_t i = 0; i < imageCount; i++) {
    CGImageDestinationAddImage(destination, frameImage.CGImage, (__bridge CFDictionaryRef)frameDestProperties);
 }

if (!CGImageDestinationFinalize(destination)) {
    NSLog(@"failed to finalize image destination");
}
CFRelease(destination);
NSURL*documentsDirectoryURL=[[NSFileManager defaultManager]URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask approvedforURL:nil创建:是错误:nil];
NSURL*fileURL=[DocumentsDirectoryUrlByAppendingPathComponent:@“animated.gif”];
CGImageDestinationRef destination=CGImageDestinationCreateWithURL((_桥CFURLRef)文件URL,kUTTypeGIF,imageCount,NULL);
CGImageDestinationSetProperties(目标,(_桥CFDictionaryRef)文件属性);
对于(大小i=0;i
它不是完整的代码,只是代码序列

我的问题是它太慢了,因为它将GIF文件保存在磁盘上

我只想使用
NSData
在内存中创建GIF文件


如何将gif图像制作成
NSData

我找到了解决方案。只需使用CGImageDestinationCreateWithData而不是CGImageDestinationCreateWithURL.:)尝试
cgmagedestinationcreatewithdata
方法。