适用于iPhone应用程序的TIFF图像格式 [英] TIFF image format for iphone application

查看:192
本文介绍了适用于iPhone应用程序的TIFF图像格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iPhone应用程序,我需要将图像保存为.tiff格式. 可以使用UIImagePNGRepresentation方法将图像保存为png格式,而使用UIImageJPEGRepresentation将图像保存为JPEG格式.但是我需要将imageview捕获的签名保存为tiff格式. 我无法使用NSImage类,因此我可以调用TIFFRepresentation方法. 我该怎么办.向我发送建议... 预先感谢...

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

推荐答案

我不知道您所说的由imageview捕获"是什么意思.直到iOS 4才引入保存为TIFF的方法.您可以使用任何文件格式数据执行此操作,无论您如何获取它.您需要链接到ImageIO框架并执行#import <ImageIO/ImageIO.h>:

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

这篇关于适用于iPhone应用程序的TIFF图像格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆