Question

Does anyone have a simple example of how to use libTiff in xcode for ios7?

The example that used to be on IBM's site has been taken down, and I have no idea where to start! I have a small 300x300 B&W UIImage (currently being output as a PNG representation) that I would like to convert to a TIFF.

Any help would be greatly appreciated.

Was it helpful?

Solution

I found the answer following David's hint.

NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *QRCode = [docPath stringByAppendingPathComponent:@"QRCode.png"];
NSMutableString *filePath = [NSMutableString string];
[filePath appendString:docPath];
[filePath appendString:@"/QRCode.png"];
NSString *destDir = @"/";
NSURL* url = [NSURL fileURLWithPath:QRCode];
CGImageSourceRef src = CGImageSourceCreateWithURL((__bridge CFURLRef)url, NULL);
NSURL* fileURL = nil;
fileURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL];
NSURL* tiff = [fileURL URLByAppendingPathComponent:@"QRCode.tif"];
CGImageDestinationRef dest = CGImageDestinationCreateWithURL((__bridge CFURLRef)tiff, (CFStringRef)@"public.tiff", 1, NULL);
CGImageDestinationAddImageFromSource(dest, src, 0, NULL);
CGImageDestinationFinalize(dest);
CFRelease(src); CFRelease(dest);

Just for reference in case anyone else has the same difficulties as me in finding a solution to this problem! I have edited the question title to reflect the solution!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top