我正在开发iphone应用程序,我需要将图像保存为.tiff格式。可以使用UIImagePNGRepresentation方法将图像保存为png格式,而UIImageJPEGRepresentation方法则可以将图像保存为JPEG格式。但我需要将图像视图捕获的签名保存为tiff格式。我无法使用NSImage类来调用TIFFRepresentation方法。我该怎么做it.Send我的建议..。提前谢谢..。
发布于 2011-02-09 18:12:50
我不知道你所说的“被影像所捕捉”是什么意思。保存为TIFF的方法直到iOS 4才被引入。下面是将任意文件保存为TIFF的示例代码;您可以使用任何文件格式的数据来实现这一点,不管您是如何获得的。您需要链接到ImageIO框架并执行#import <ImageIO/ImageIO.h>
NSURL* url = [[NSBundle mainBundle] URLForResource:@"colson" withExtension:@"jpg"];
CGImageSourceRef src = CGImageSourceCreateWithURL((CFURLRef)url, NULL);
NSFileManager* fm = [[NSFileManager alloc] init];
NSURL* suppurl = [fm URLForDirectory:NSApplicationSupportDirectory
inDomain:NSUserDomainMask
appropriateForURL:nil
create:YES error:NULL];
NSURL* tiff = [suppurl URLByAppendingPathComponent:@"mytiff.tiff"];
CGImageDestinationRef dest = CGImageDestinationCreateWithURL((CFURLRef)tiff,
(CFStringRef)@"public.tiff", 1, NULL);
CGImageDestinationAddImageFromSource(dest, src, 0, NULL);
bool ok = CGImageDestinationFinalize(dest);
NSLog(@"result %i", ok); // 1, all went well
// and don't forget memory management, release source and destination, NSFileManager
[fm release]; CFRelease(src); CFRelease(dest);
发布于 2010-09-21 05:56:48
嗯,我不为iPhone开发,所以不能告诉您是否有一种神奇的API方法,但是很多年前我不得不手动创建TIFF映像。
如果您习惯于只使用框架的CreateThisStuffAsAnImage()方法,那么TIFF格式有点古怪,但是您可以在这里获得规范并自己创建文件:
http://partners.adobe.com/public/developer/tiff/index.html#spec
https://stackoverflow.com/questions/3751535
复制相似问题