2010-09-20 33 views
1

我正在iphone應用程序上工作,我需要將圖像保存爲.tiff格式。 使用UIImagePNGRepresentation方法和使用UIImageJPEGRepresentation的JPEG格式可以將圖像保存爲png格式。但我需要將通過imageview捕獲的簽名保存爲tiff格式。 我無法使用NSImage類,因此我可以調用TIFFRepresentation方法。 我該怎麼做。發送我的建議... 在此先感謝...iPhone應用程序的TIFF圖像格式

回答

0

嗯,我不開發的iPhone,所以不能告訴你,如果有一個神奇的API的方式做到這一點,但很多年前我不得不手動創建TIFF圖像

TIFF格式是有點怪的,如果你已經習慣了只使用一個框架的CreateThisStuffAsAnImage()方法,但你可以在這裏得到規範和自己創建的文件:

http://partners.adobe.com/public/developer/tiff/index.html#spec

1

我不不知道你的意思是「被imageview捕獲」。直到iOS 4才引入保存爲TIFF的手段。下面是將任意文件保存爲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);