Is that possible to take photo from camera along with date, time and location(lat n long) display in photo in iphone.
-
3You just want somebody to write your application, huh!? – El Tomato Jul 19 '13 at 04:21
-
1No . i want to know is that possible or not – Muruganandan Pandi Jul 19 '13 at 04:34
-
1See these search results: http://stackoverflow.com/search?q=uiimagepickercontroller+image+metadata – rmaddy Jul 19 '13 at 04:37
-
1ya i got date time details . i am asking while taking picture in picture it should display time,date,loc details like in digital camera – Muruganandan Pandi Jul 19 '13 at 06:39
-
yes you can show it like it is in digital camera. – Kundan Jul 19 '13 at 10:00
1 Answers
Yes this is possible,
You need to use UIImagePickerController with a custom overlay view...
From Apple's docs @ http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html
You can customize an image picker controller to manage user interactions yourself. To do this, provide an overlay view containing the controls you want to display, and use the methods described in “Capturing Still Images or Movies.” You can display your custom overlay view in addition to, or instead of, the default controls. Custom overlay views for the UIImagePickerController class are available in iOS 3.1 and later by way of the cameraOverlayView property. For a code example, see the PhotoPicker sample code project.
Further more, you can get all the data you need, time, geo coordinates etc from UIImagePickerControllerMediaMetadata
Which you can use to populate labels on your custom overlay view.
If you don't want to use this method you can also do it easily using AVCamCaptureManager and AVCamRecorder classes.
As Per This Questions answer...
"Apple has a demo program build on its developer site here. It is named AVCam. In simple words what it does is when you click to open the camera, it calls the classes and methods which are responsible for opening the iPhone's camera and record video or capture audio. It calls the same classes which are called by UIImagePickerController. So your camera will open and start taking input. Now, if you open the xib file of that AVCam project, you'll find a small UIView object. This view is responsible for displaying the camera's feed. You can resize that view as per the size you want and the camera's input will be displayed in that much area. You can also put the frame image around it as per your choice."
Code to add strings to UIImage after taking picture:
//Add text to UIImage
-(UIImage *)addText:(UIImage *)img text:(NSString *)text1{
int w = img.size.width;
int h = img.size.height;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst);
CGContextDrawImage(context, CGRectMake(0, 0, w, h), img.CGImage);
CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1);
char* text = (char *)[text1 cStringUsingEncoding:NSASCIIStringEncoding];// "05/05/09";
CGContextSelectFont(context, "Arial", 18, kCGEncodingMacRoman);
CGContextSetTextDrawingMode(context, kCGTextFill);
CGContextSetRGBFillColor(context, 255, 255, 255, 1);
//rotate text
CGContextSetTextMatrix(context, CGAffineTransformMakeRotation( -M_PI/4 ));
CGContextShowTextAtPoint(context, 4, 52, text, strlen(text));
CGImageRef imageMasked = CGBitmapContextCreateImage(context);
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
return [UIImage imageWithCGImage:imageMasked];
}
-
i want to display the picture with date and time like in digital camera – Muruganandan Pandi Jul 19 '13 at 07:18
-
Yes, I know that. use the above information to add whatever you like to the camera UI, and use the code above to add text strings (for date/time/location to the UIImage returned using the UIImagePickerController. – Woodstock Jul 19 '13 at 07:22
-
With the above code you can take the UIImage object captured by the camera and returned to you in the delegate method didFinishPickingMediaWithInfo and add any info you like to it, before saving to camera roll etc. – Woodstock Jul 19 '13 at 07:26
-
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType]; if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { editedImage = [info objectForKey:UIImagePickerControllerOriginalImage]; [self addText:editedImage text:@"2113"]; } NSDictionary *metadataDictionary = (NSDictionary *)[info valueForKey:UIImagePickerControllerMediaMetadata]; [imgpicker dismissViewControllerAnimated:NO completion:nil]; self.imageview.image = editedImage; } – Muruganandan Pandi Jul 19 '13 at 07:33
-
I've answered your original question on technical feasibility. - in a quite detailed fashion, showing you each part you need to implement, if this question is answered please mark it as so. If you need to ask a further question about the implementation of text on UIImages please open another question. – Woodstock Jul 19 '13 at 13:07