iPhone SDK and Multipage tiff - iphone-sdk-3.0

I need to access the iphone APIs to read a multipage TIFF image file format, dose anyone know how:, if not how can I build and use the open source libtiff on iphone/xcode.

I've created my own solution for this: NSTiffSplitter.
You can find it on github.
NSString *pathToImage = [[NSBundle mainBundle] pathForResource:#"Example" ofType:#"tiff"];
NSTiffSplitter* splitter = [[NSTiffSplitter alloc] initWithPathToImage:pathToImage];
UIImage *page = [[UIImage alloc] initWithData:[splitter dataForImage:page]];
yourImageView.image = page;
[page release];

Related

Swift equivalent of initWithContentsOfFile using image

In Objective C I was using this code to scale an image to my background. How can I achieve this in Swift.
path = [[NSBundle mainBundle] pathForResource:#"This" ofType:#"png"];
image = [[UIImage alloc] initWithContentsOfFile:path];
you can try this:
path = NSBundle.mainBundle().pathForResource("This", ofType: "png")
image = UIImage(contentsOfFile: path)

Can't see pdf in UIWebView (the app is approved by Apple)

One of my app's functions is to present PDF file (from app bundle) in a UIWebView.
On my iPhone it works fine, but I've got some reports that on other devices PDF file isn't presented.
What could be the problem? Could it have something to do with iOS version on those devices?
This is how I present the file inside the app:
NSString *pdfPath = [[NSBundle mainBundle] pathForResource:self.fileName ofType:#".pdf"];
if (!pdfPath) {
Helper* h = [[Helper alloc]init];
pdfPath = [h filesinADocumentFolder:self.fileName];
}
self.pdfUrl = [NSURL fileURLWithPath:pdfPath];
[self.webView1 loadRequest:[NSURLRequest requestWithURL:pdfUrl]];
[self.webView1 setBackgroundColor:[UIColor clearColor]];
[self.webView1 setOpaque:NO];

Export image to Instagram - iPhone

I have an image and I want to export it to Instagram, so I can post it.
The code I'm using is:
NSURL *instagramURL = [NSURL URLWithString:#"instagram://location?id=1"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:#"Documents"];
NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:#"Image.igo"];
UIImage *image = [UIImage imageNamed:#"01.png"];
NSData *imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:savedImagePath atomically:YES];
NSURL *imageUrl = [NSURL fileURLWithPath:savedImagePath];
NSLog(#"%#",imageUrl);
UIDocumentInteractionController *docController = [[UIDocumentInteractionController alloc] init];
docController.delegate = self;
docController.UTI = #"com.instagram.exclusivegram";
docController.URL = imageUrl;
//[docController setURL:imageUrl];
[docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
}
When I run the app, the App shows the button written "Instagram" its icon, but when I touch it, the button disappear, and nothing happens. The app didn't crash, but nothing happen.
What I missed in my code ?
Regards
Bruno
I guess the problem is you do not retain the UIDocumentInteractionController. Make an ivar for it in your class.
Make sure the method documentInteractionController:didEndSendingToApplication: is called on the delegate.
Also check out the Instagram documentation: http://instagram.com/developer/iphone-hooks/
When triggered, Instagram will immediately present the user with our
filter screen. The image is preloaded and sized appropriately for
Instagram. Other than using the appropriate image format, described
above, our only requirement is that the image is at least 612px tall
and/or wide. For best results, Instagram prefers opening a JPEG that
is 612px by 612px square. If the image is larger, it will be resized
dynamically.
To verify that Instagram is installed check for the URL instagram://app. The URL instagram://location?id=LOCATION_ID is intended for location feeds only!

Thumbnail from NSURL

I am loading files that are downloaded from the web in a UIWebView (HTML files).
Is there a way to create a UIImage from an HTML file located in the Documents folder?
The goal is to auto generate thumbnails without needing to manual create them...
Update
My train of thought would be to do something in the line of:
NSString * s = [[NSBundle mainBundle] pathForResource:#"test" ofType:#"html"];
UIImage *image = [[UIImage alloc] initWithData:
[NSData dataWithContentsOfURL:url]];
Which of course does not work in this case!
Thanks!
S.
I found this solution here
UIGraphicsBeginImageContext(yourWebView.bounds.size);
[yourWebView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *resultImageView = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
resultImageView will be an image that contains the render of yourWebView.
If you want to shrink it down to a thumbnail size from there, I like Trevor's UIImage category for that purpose.

How to display images from plist in cocoa mac

I am developing mac desktop app using objective c. i have array of images to display one after one when button pressed, so i am want to use plist to store image names and i want to display image on image view using plist.
Just load your plist where you stored you image's paths to an array like this :
NSString *myfile = [[NSBundle mainBundle]
pathForResource:#"images" ofType:#"plist"];
imagesArray = [[NSArray alloc] initWithContentsOfFile:myfile];
and then when you want to display an image, juste get it's path from the array above, example :
UIImage *img = [UIImage imageNamed: [imagesArray objectAtIndex:4]];
myImageView.image = img;