PDA

View Full Version : strange imagepicker problem




chhoda
Nov 12, 2009, 07:46 AM
Hi All,

while using imagepicker sourcetype camera, I observed that when I use the image returned by

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo

straightaway, the image is rotated 90degre down. This happens only in camera mode. For the time being I was able to have my image rotate 90 degrees up. But is this problem a known issue ?

furthermore, when i just put it in the backgound, the image seems alright. when I try to resize it, it gets rotated.

bit strange though, anybody else has noticed this ?

CH



dejo
Nov 12, 2009, 09:57 AM
Up and down are not normal descriptions for 90 rotations in a 2D space. Usually it's left / right or counter-clockwise / clockwise. Care to explain?

chhoda
Nov 13, 2009, 05:48 AM
mostly when we get UIImage from camera or Camera Roll, we get UIImage with orientation UIImageOrientationRight

I had to check that and rotate the movie to appear proper.

but when the image was picked from album, it was proper

CH

chhoda
Nov 13, 2009, 07:46 AM
i observed, imagepicker when called from my app is very slow. visibly slower than native camera app. And in a few cases while using photo [clicking USE button] it crashed. I tried to see if any memory issues are there by using Leak detector of xcode. Memory leak was mostly caused from UIImagePickerViewController

where as I am simply using a UIImagePickerController vriable with propery (nonatomic, retian)

and releasing and allocating it again when i need to call it.

I dont know what could be causing this problem.

what does ObjectAlloc does ? how to interprete that graph ? There I saw total alloc somewhere 1.5 mb, is it normal ? any application while running will hold some memory, isn't it ? my executable is 2.5mb

Any pointers in here would be appreceated.

this is only happening in device, not in simulator
CH

dejo
Nov 13, 2009, 09:38 AM
Any pointers in here would be appreceated.
We probably won't be able to provide any without seeing a lot more code.

chhoda
Nov 14, 2009, 05:34 AM
I am using simplistic approach.
@interface MyViewController : UIViewController < UIImagePickerControllerDelegate> {
UIImage *pickedImage;
UIImagePickerController *pickerController;
}

@property (nonatomic, retain) UIImage *pickedImage;
@property (nonatomic, retain) UIImagePickerController *pickerController;

@end

@implementation MyViewController

-(IBAction) buttonClick {
[pickerController release];
pickerController = [[UIImagePickerController alloc] init];
pickerController.delegate = self;

if(currentImageIndex == 1)
pickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
if(currentImageIndex == 0)
pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;

[appDelegate.window addSubview:pickerController.view];

}


// delegates

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
[picker dismissModalViewControllerAnimated:YES];
[picker.view removeFromSuperview];

currentImageIndex = -1;
[pickedImage release]; // release old ones before using new ones
// Sometimes, iphone camera automates the rotation to landscape, to catch this to proper mode, we need to check and reorient it
if(UIImageOrientationRight == [image imageOrientation]) {
pickedImage = [[image rotate:UIImageOrientationRight] retain]; // rotate(image, UIImageOrientationRight);
}
else
pickedImage = [image retain];
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissModalViewControllerAnimated:YES];
[picker.view removeFromSuperview];
}

@end

chhoda
Nov 15, 2009, 12:50 AM
Again, I observed, in instruments app, when imagepicker is alloced, memory allocation goes up by 40k when i release it memory comes downn only ~5k !

CH

chhoda
Nov 16, 2009, 09:40 AM
As it turned out, the imagepicker returns an image with width 1200 and height 1600 , and my image manipulation work was failing. Why is it so, the camera returns so big an image ?

CH