开发者

TIFF image format for iphone application

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...


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);


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜