Passing a UIIImage to UIImagePickerController for editing - ios

Is it possible to provide UIImagePickerController a UIIMage object, to use editing functionality provide this pickerController.
This is how I am trying to implement it.
-(IBAction) openEditor:(id) sender{
UIImagePickerController *pickerCntrl=[[UIImagePickerController alloc] init];
pickerCntrl.sourceType=UIImagePickerControllerSourceTypeSavedPhotosAlbum;
pickerCntrl.allowsEditing=YES;
[self presentViewController:pickerCntrl animated:YES completion:nil];
}
But, for this Image must be already present in the Album. Another thing is it provides a UI for you to select the Image.
I am trying to open directly the following window on openEditor:(id) sender.

The UIImagePickerController is for picking an image (either from the photo library or the camera). It can't be used for any kind of editing of any arbitrary image you wish to supply.
If you want to provide scaling and cropping of your own image then you must implement your own image editing controller.
Either implement your own or look into a 3rd party library that already does this. I've had good luck with the Aviary SDK.

Related

How to get uiimagepicker Spinner button action in iOS?

I'm using below code.
self.picker=[[UIImagePickerController alloc] init];
self.picker.delegate=self;
self.picker.allowsEditing=NO;
self.picker.sourceType=UIImagePickerControllerSourceTypeCamera;
self.picker.cameraOverlayView=[self addCameraRollButton];
[self presentViewController:self.picker animated:NO completion:NULL];
How to take picture from camera without going to Usephoto page. I want to stay on camera view. I'm not able to get camera spinner action.I used custom overlay but in that Square focus not coming.Please help me.I want all default camera features.
Once you use custom overlay you will not be able to see default camera features.If you want all default features you should use
self.picker.showsCameraControls = YES;
This opens default camera and you can see all features.
If you want to go with custom overlay then you need to built all features.

iOS, some questions about camera control

I am newbie to iOS programming.
I have a few simple questions.
After picking image from gallery or taking a picture from camera, I want to select
rectangle area like android
UIImagePickerController * picker =[[UIImagePickerController alloc] init];
picker.delegate=self;
picker.allowsEditing=YES;
picker.sourceType=UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:nil];
When I use this code, I can't resize my area as you see below
.
It is related to first question.
As you see my image is resized and changed to different ratio.
But I want image is fixed with original ratio.
Anyone knows how to use camera in iOS simulator?
Question 3: You cannot use the camera function in simulator. That is one of the limitations. See this document from Apple Developer page: https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/iOS_Simulator_Guide/TestingontheiOSSimulator/TestingontheiOSSimulator.html
Question 2: below
This is answer is from this link: How to make UIImageView automatically resize to the size of the image loaded
UIImage img = [UIImage imageNamed:#"myImage.jpg"];
[imageView setImage:img];
imageView.frame = CGRectMake(imageView.frame.origin.x, imageView.frame.origin.y,
img.size.width, img.size.height);
"This will however not change the layout of view it is contained within, you can make it change the sizes of the other views automatically under iOS 6 using Layout Constraints. If you are an Apple Developer you can watch the WWDC instruction videos, they explain how that system works quite well."
It's the best answer I have as it is the way I use setting image sizes in a view.

Take photo and store in custom album in Xamarin.iOS

I want to take a photo and save them within a custom album on a iPad.
I tried a lot of things but ended always with wrong image orientation.
My current procedure is:
Take photo with Xamarin.Media and safe image somewhere in my app path
Create custom album if it's not existing
Load image from temporary path and save to the album
Add the image (asset) additionally to the custom album created in 2.
The workflow above is fully working except of saving the correct orientation. After loading an image with library.AssetForUrl() the containing orientation is every time up. Also after converting from asset -> CGImage -> UImage (uiImage.Orientation).
In step 3 I tried to set the orientation the the appropriate one with
var image = new UIImage(tempImage.CGImage, 1.0f, UIImageOrientation.MyOrientation)
and also with the save command
library.WriteImageToSavedPhotosAlbum(image.CGImage, myOrientation, SaveCompletionBlock)
But the orientation is still ignored. I checked this by opening the Album application as well as loading the file in my self written gallery app.
I want to avoid the use of the iOS picker to take photos. This will produce a mess of code!
Or is there any third party library which allows to take photos and store them in a custom album? Which takes care of all the metadata information? It doesn't matter if it's written in objective-c or c#. I will create bindings for it. But it's awful to work with the camera and albums in iOS.
There are tons of hand-made UIImagePickerController alternatives. Some of them:
https://github.com/w5mith/WSAssetPickerController
https://github.com/chute/photo-picker-plus-ios
https://github.com/B-Sides/ELCImagePickerController

UIImagePickerController always pics 640x640 image

When I present a UIImagePickerController in my iPhone App, it always comes up with a white square with a frame around it, and the user has can zoom in and out of an image and make it fit within the white square. Whatever they fit in the white square is what is returned to:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)info
and it is always 640x640.
Why can't the user select an entire image? Why does this white square even come up?
Built in editing is very limited. Here is what the Apple documentation says:
Editing controls To specify whether the camera interface should offer
the user controls for moving and scaling the captured picture, or for
trimming the captured movie, set the allowsEditing property to YES (to
provide editing controls) or to NO.
When using built-in editing controls, the image picker controller
enforces certain options. For still images, the picker enforces a
square cropping as well as a maximum pixel dimension. For movies, the
picker enforces a maximum movie length and resolution. If you want to
let the user edit full-size media, or specify custom cropping, you
must provide your own editing UI.
Make sure you're not enable editing for the UIImagePickerController.
You just need this:
UIImagePickerController* imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[imagePicker setDelegate:self];
[controller presentModalViewController:imagePicker animated:YES];
[imagePicker release];

How to remove the "Preview" view after I take a picture in UIImagePickerController?

I'm using UIImagePickerController to take pictures. It's quite simple. But I have a problem: There is always a "Preview" view to let me "Retake" or "Use". Which is not what I want. I want to save my pictures straight away inside my photo albums.
I've found some articles about this problem, here are some of them:
Link 1
Link 2
Basically they are using a OverlayView which can solve the problem. But there is new problem. I can't use volume up key to take pictures anymore after I use OverlayView. Are there another solution to disable the stupid "Preview" ?
Thanks
You could access the camera directly and not use UIImagePickerController at all.
Check out the following classes:
AVCaptureSession
AVCaptureDevice
AVCaptureDeviceInput
AVCaptureVideoDataOutput
With these classes you can display your own camera preview and save the image when button is pressed.
There is example here:
http://developer.apple.com/library/ios/#qa/qa1702/_index.html

Resources