TIFF image format for iphone application

余生长醉 提交于 2019-12-11 10:45:48

问题


I am working on iphone app and i need to save image into .tiff format. It is possible to save image into png format using UIImagePNGRepresentation method and JPEG format using UIImageJPEGRepresentation. But i need to save signature captured by imageview into tiff format. I unable to use NSImage class so that i can call TIFFRepresentation method. How can i do it.Send me suggestion... Thanks in advance...


回答1:


I don't know what you mean by "captured by imageview". The means to save as TIFF wasn't introduced until iOS 4. Here is example code to save an arbitrary file as a TIFF; you can do this with any file-format data, no matter how you obtained it. You need to link to ImageIO framework and do #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);



回答2:


Hmm, I don't develop for the iPhone, so can't tell you if there's a magic API way of doing this, but many years ago I had to create TIFF images manually.

The TIFF format is a bit whacky if you're used to just using a framework's CreateThisStuffAsAnImage() methods, but you can get the spec here and create the file yourself:

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



来源:https://stackoverflow.com/questions/3751535/tiff-image-format-for-iphone-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!