How to use the picture takes from camera? - iphone

Iam developing one application.In that i want to take the picture from camera.For that i used the UIImagePickerControllerSourceTypeCamera.But my problem is how to get that image intomy application.Please tell me how to manage that one.

Thats pretty simple. You have a method in UIImagePickerController which is
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImageWithMediaInfo(NSDictionary *)info. You can get here the image user had selected from UIImagePickerControllerSourceTypeCamera. Now declare an object of UIImage in the header of your AppDelegate. For example I declare UIImage *pickedImage. The purpose to declare this in AppDelegate is that we can use this Image anywhere in our app. Dont retain and synthesize this object. Now come back to your didFinishPickingImage method and now your body of this method should look like this:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)info {
((AppDelegate*)[UIApplication sharedApplication].delegate).pickedImage= [info objectForKey: UIImagePickerControllerOriginalImage];
}
Now you can easily use this image all over your app by just calling ((AppDelegate*)[UIApplication sharedApplication].delegate).pickedImage. Hope it helps.
Happy Coding!

Related

How to reuse camera after take a photo?

I have a simple question: how to use (show) again a camera after take a photo?
I use UIImagePickeController and when the photo was taken (Use button was tapped) we go to delegate:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
How to tell camera to appears one again?

How can I hide the picture preview?

I am new in iPhone development,
I have built new app to take a picture using UIImagePickerController.
Everything is work fine with me, but I need to dismiss the picture preview that appear after I press the capture button.
I search through the net then I found I must use the following routine.
(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo
{
[self dismissModalViewControllerAnimated:YES];
}
but it didn't work.
Any help or suggestions, is highly appreciated.
You need to add your own camera overlay view. This view should have a button on to Take a picture.
To add an overlay view, create a view with a background colour of clear, then assign your overlay view to the picker control
self.imagePickerController.showsCameraControls = NO;
self.imagePickerController.cameraOverlayView = myOverlayView;
Then in your overlay view button event you call the following:
[imagePickerController takePicture];
This will then fire the following method on the imagePickerDelegate, and you can save your photo etc in there
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

How to programmatically take a low resolution snapshot using camera?

I am developing a fax client that is able to take snapshots. It communicates to the server via web service calls. Is there a way to reduce the image resolution so that we can have faster uploads and downloads? Right now the user has to wait a good 50 seconds for anything to happen.
This is the code I am using presently:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
[image setImage:img];
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
}
You have to resize the image the ImagePickerController gives you before you send it. You can find many informations and UIImage categories on this article : http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/

IPhone - UIImage to Binary String

I have this bit of code that get the image i have picked from the Camera and displays it into a UIImageView. I want to convert the image to a binary string so i can then make a URL call and pass it back to the server. How would I modify this code to get my binary string?
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo {
imageView.image = image;
[picker dismissModalViewControllerAnimated:YES];
}
You should better pass the NSData got from image jpeg representation to the server by POST method.
Marco
You can find an example of how to do it from Apple in this technote. Not as easy as it should be, but appears that it's the only way to do it. Is it possible for you to get the data before it becomes a UIImage to make your life a little easier? If not, just try the method presented at the link.

UIImagePickerController in iPhone OS 3.0

I am using iPhone OS 3.0 SDK.
My requirement is that I want to get the image from the photo albums library and display it on an image view.
I am using the UIImagePickerController for that.
But the problem is the - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)imageeditingInfo:(NSDictionary *)editingInfo delegate method is deprecated in iPhone OS 3.0 ,
Is there any alternative for getting the Image from the UIImagePickerController.
All suggestions are highly appreciated.
Thanks...
use this delegate method of UIImagePickerController in your implementation file.
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
imageView.image = [info objectForKey:#"UIImagePickerControllerOriginalImage"];
}
and don't forget to modify your header file with these two protocols
#interface photoAppViewController : UIViewController < UIImagePickerControllerDelegate,UINavigationControllerDelegate >
Speaking of 3.0 here would break your and my NDA with Apple. However I can suggest that you look at the relevant header files (mdfind didFinishPickingImage | grep 3.0 will find what you need quickly).
Some one posted me the answer as below.
In UIImagePickerController.h you can see that there ist a method you
can use:
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info;
The documentation does not show this method it is only in the .h file.
but I am still not getting the above method in the .h file