How to open the camera from the native application in iphone?

I want to write an application in which I open the camera, take a picture, and then edit the image. I want to apply some interesting effects on the image. Something like image editing ... does anyone know a good one or am I talking about the best approach to this?

I want to know what open-gl is needed to create aap as image editing?

+3
source share
2 answers

It is really easy. Your code will be in a subclass UIViewController, even if this class complies with the protocol UIImagePickerControllerDelegate, this allows your controller to receive images from the camera and / or user library.

Now you need to create and display UIImagePickerController, this controller can be used to select images from the user library and to capture images / videos from the camera. Implement something like this:

-(IBAction)takePictureWithCamera {
  UIImagePickerController* controller = [[UIImagePickerController alloc] init];
  controller.delegate = self;
  [self presentModalViewController:controller animated:YES];
  [controller release];
}

This will display the image picker, see the documentation for UIImagePickerControllerhow to configure it if necessary.

Then you need to get an image that the user selects or takes with the camera. This is done by implementing the method imagePickerController:didFinishPickingMediaWithInfo:from the protocol UIImagePickerControllerDelegate.

-(void)imagePickerController:(UIImagePickerController*)picker
    didFinishPickingMediaWithInfo:(NSDictionary*)info {
  UIImage* image = [info objectForKey: UIImagePickerControllerOriginalImage];
  // Do stuff to image.
}

And it's all.

+4
source

UIImagePickerController. , , "" , iPhone .

+2

Source: https://habr.com/ru/post/1717701/


All Articles