Problem! Add a .tiff image in my iOS4 app - iphone

I use Adobe Photoshop,created a .tiff image.
Then I attach this image to an UIImageView.
Code Like:
UIImage *img = [UIImage imageNamed:#"xxx.tiff"];
UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
[self.view addSubview:imgView];
But,the image is not completely displayed.It's very rough and lost many details!
How can I deal with it?

If you have access to Photoshop why would you choose to save a TIFF?
PNGs are the fastest and most supported image format on the iPhone, save it as a PNG instead!

Related

show image from sqlite database in uiimageview

I have stored image path in sqlite and I successfully fetched image path from the database. I stored it in a string. I print the path in the console which is as follows:
2012-10-26 11:54:37.888 valvolineApp[1211:207] Image path:/Users/shufflelabs/Library/Application Support/iPhone Simulator/5.0/Applications/6B6D67DB-92AB-48C5-856B-861423FB22F4/valvolineApp.app/11_fuel system service.jpg
but now how to show the respective image in the uiimageview?
I am very confusing here.
share the idea if you have
thanx...
Try this
UIImage *img = [UIImage imageWithContentsOfFile:(the file path)];
UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
If u still facing problem similar posts are seen below.
programmatically-show-image-in-uiimageview-iphone
dispay-image-in-uiimageview
how-to-display-images-in-imageview-in-iphone

Which animated file types are supported by iOS?

I just want to add an animated file to my application.
Most of the postings I have read, are using UIImageViews or collection of the multiple images. I don't want to do that.
I just want to know which animated file formats are working on iOS (I know .gif and .swf are not working on iOS).
So is there any other file format, which I can use in my app OR let me know if there is any other framework to use the animated file.
You may use gif. You need to show inside UIWebView.
we cant use any animated file like .gif, .swf because apple not allows us. if you want to animate the images just do that way.
UIImageView* campFireView = [[UIImageView alloc] initWithFrame:self.view.frame];
// load all the frames of our animation
campFireView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:#"campFire01.png"],
[UIImage imageNamed:#"campFire02.png"],
[UIImage imageNamed:#"campFire03.png"],
[UIImage imageNamed:#"campFire04.png"],
[UIImage imageNamed:#"campFire05.png"],
[UIImage imageNamed:#"campFire06.png"],
[UIImage imageNamed:#"campFire07.png"],
[UIImage imageNamed:#"campFire08.png"],
[UIImage imageNamed:#"campFire09.png"],
[UIImage imageNamed:#"campFire10.png"],
[UIImage imageNamed:#"campFire11.png"],
[UIImage imageNamed:#"campFire12.png"],
[UIImage imageNamed:#"campFire13.png"],
[UIImage imageNamed:#"campFire14.png"],
[UIImage imageNamed:#"campFire15.png"],
[UIImage imageNamed:#"campFire16.png"],
[UIImage imageNamed:#"campFire17.png"], nil];
// all frames will execute in 1.75 seconds
campFireView.animationDuration = 1.75;
// repeat the annimation forever
campFireView.animationRepeatCount = 0;
// start animating
[campFireView startAnimating];
// add the animation view to the main window
[self.view addSubview:campFireView];
or see that link www.appsamuck.com/day2.html
By default a GIF won't animate correctly in a UIImageView. However, with a little extra effort you can get them to work.
This project looks the most promising as it appears to actually decode the gif and display the individuals frames for you.
https://github.com/arturogutierrez/Animated-GIF-iPhone/
Otherwise, the other solutions I've seen are what you mentioned. (Separating the gif into multiple images manually)
http://www.alterplay.com/ios-dev-tips/2010/12/making-gif-animating-on-ios.html
You can use cocos2D for this animation. Use with CCSpriteSheet.

UIImage display differently when saving and loading from file

I'm download jpeg picture from web server and load it to UIImage.
If I display the UIImage in UIImageView directly, I see the picture correctly.
But if i cache the image to file with :
[UIImageJPEGRepresentation(image,1.0f) writeToFile:sFilePath atoimcally:YES]
and load it with :
image=[UIImage imageWithContentsOFile:sFilePath]
and display this in the same UIImageView, I can see white stripes in the sides of the picture.
again, Exactly the same UIImageView object with the same properties settings in it.
Why is that?
You can simply write to a file the NSData you have loaded from the web, without going through the UIImageJPEGRepresentation routine.
[dataObject writeToURL:fileURL atomically:YES];
and to retrieve
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[fileURL path]];
That works really well in my app.

scale image of size 1600*1200

I am developing image size based iphone application. selecting two photos of size 1600*1200 from photo library and merging of both to single image and save to same library. Again if i check the image size it shows 600* 800. How to get original size(1600*1200) of created New photo(600*800).
Thanks in advance.
Check the UIImagePickerControllerDelegate Protocol Reference.
The info NSDictionary of the imagePickerController:didFinishPickingMediaWithInfo: method contains the original image.
Solved as follows.
UIView *bgView = [[UIView alloc] initwithFrame:CGRectMake(0,0,1600,1200)];
UIGraphicsBeginImageContext(tempView.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage,self,nil,nil);
Thanks for all your support to solve the issue.

Does UIImage's -imageNamed: method work for image files stored in 'Documents'?

My app downloads a small image file from a remote server and I am trying to display it along with some other small image files that are pre-installed in the app. I am using [UIImage imageNamed:#"TheImageName.png"] to get the images (see below for more detail). The pre-installed images display as expected but the image in my apps 'Documents' directory is no where to be found. Should I be using -imageNamed for an image in 'Documents' or some other method?
UIImage* documentsImage = [UIImage imageNamed:#"TheImageName.png"];
UIImageView* anImageView = [[UIimageView alloc] initWithImage:documentsImage];
[self.view addSubview:anImageView];
Ah, nevermind. I found that using [UIImage imageWithContentsOfFile:filePath] works for this. imageNamed just returns nil.
No, +imageNamed: only loads images from the app bundle.
Also, don't include the .png extension when using that class method.