Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

chhoda

macrumors 6502
Original poster
Oct 25, 2008
285
1
Hi All,

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

Code:
- (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
 
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?
 
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
 
surprising

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
 
I am using simplistic approach.
Code:
@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
 
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
 
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.